Git Repository

Stackyard

Stackyard scannt lokale Entwicklungsordner und bündelt Projekte, Git-Status, TODOs, Toolchains, Docker-Compose-Setups, Datei- und Launcher-Funktionen sowie Operations-Informationen in einer lokalen WebUI.

Projektseite ↗
HTTPShttps://zanvex.de/git/stackyard.git

internal/launcher/launcher_test.go

Zum Verzeichnis
package launcher

import (
	"runtime"
	"testing"

	"stackyard/internal/config"
)

func TestConfiguredCommandUsesConfiguredBinary(t *testing.T) {
	spec, err := configuredCommand(config.LauncherConfig{
		Enabled: true,
		Command: "code --reuse-window",
	}, []string{"/tmp/project"})
	if err != nil {
		t.Fatalf("configuredCommand: %v", err)
	}
	if spec.name != "code" {
		t.Fatalf("unexpected command name: %q", spec.name)
	}
	if len(spec.args) != 2 || spec.args[0] != "--reuse-window" || spec.args[1] != "/tmp/project" {
		t.Fatalf("unexpected args: %#v", spec.args)
	}
}

func TestPlatformCommandRejectsDisabledLauncher(t *testing.T) {
	if _, err := platformCommand(config.LauncherConfig{}, []string{"/tmp/project"}, []string{"xdg-open", "/tmp/project"}); err == nil {
		t.Fatal("expected disabled launcher error")
	}
}

func TestSplitCommandLineKeepsQuotedPaths(t *testing.T) {
	parts := splitCommandLine(`"/mnt/c/Program Files/Microsoft VS Code/Code.exe" --reuse-window`)
	if len(parts) != 2 {
		t.Fatalf("unexpected parts: %#v", parts)
	}
	if parts[0] != "/mnt/c/Program Files/Microsoft VS Code/Code.exe" {
		t.Fatalf("unexpected command: %q", parts[0])
	}
}

func TestToWindowsCommand(t *testing.T) {
	if runtime.GOOS != "linux" {
		t.Skip("WSL path translation only relevant on Linux/WSL")
	}
	got := toWindowsCommand("/mnt/c/Windows/explorer.exe")
	if got == "/mnt/c/Windows/explorer.exe" {
		t.Fatalf("expected windows path conversion, got %q", got)
	}
}