//go:build linux package microvm import ( "strings" "testing" "tangled.org/core/spindle/models" "tangled.org/core/spindle/secrets" ) func TestDebugSSHCommandUsesJumpHost(t *testing.T) { got := debugSSHCommand("0.0.0.0:2224", "executor-a.internal", "executor-a", "spindle.example", "job-1") want := "ssh -tt -J spindle.example -p 2224 job-1@executor-a" if got != want { t.Fatalf("debug ssh command = %q, want %q", got, want) } } func TestDebugSSHCommandUsesExecutorHostWithoutJump(t *testing.T) { got := debugSSHCommand("0.0.0.0:22", "executor-a.example", "", "", "job-1") want := "ssh -tt job-1@executor-a.example" if got != want { t.Fatalf("debug ssh command = %q, want %q", got, want) } } func TestStepEnvironmentPreservesFailedStepContext(t *testing.T) { workflow := &models.Workflow{ Environment: map[string]string{ "CI": "true", "OVERRIDE": "workflow", }, } step := Step{ environment: map[string]string{ "OVERRIDE": "step", "STEP_ONLY": "yes", }, } unlocked := []secrets.UnlockedSecret{{ Key: "SECRET", Value: "value", }} got := make(map[string]string) for _, value := range stepEnvironment(workflow, step, unlocked) { key, value, ok := strings.Cut(value, "=") if ok { got[key] = value } } want := map[string]string{ "HOME": "/workspace", "LOGNAME": guestWorkflowUser, "PATH": guestBasePATH, "USER": guestWorkflowUser, "CI": "true", "OVERRIDE": "step", "STEP_ONLY": "yes", "SECRET": "value", } for key, value := range want { if got[key] != value { t.Errorf("%s = %q, want %q", key, got[key], value) } } }