package execx import ( "bytes" "context" "log" "strings" "testing" ) // TestRunnerDryRun runs one orchestration or CLI step. // Signature: TestRunnerDryRun(t *testing.T). // Why: keeps behavior explicit so startup/shutdown workflows remain maintainable as services evolve. func TestRunnerDryRun(t *testing.T) { var buf bytes.Buffer r := &Runner{ DryRun: true, Logger: log.New(&buf, "", 0), } out, err := r.Run(context.Background(), "echo", "hello") if err != nil { t.Fatalf("dry-run should not fail: %v", err) } if out != "" { t.Fatalf("expected empty dry-run output, got %q", out) } if !strings.Contains(buf.String(), "DRY-RUN: echo hello") { t.Fatalf("expected dry-run log entry, got %q", buf.String()) } } // TestRunnerRunSuccess runs one orchestration or CLI step. // Signature: TestRunnerRunSuccess(t *testing.T). // Why: keeps behavior explicit so startup/shutdown workflows remain maintainable as services evolve. func TestRunnerRunSuccess(t *testing.T) { r := &Runner{} out, err := r.Run(context.Background(), "sh", "-c", "printf ok") if err != nil { t.Fatalf("expected command success: %v", err) } if out != "ok" { t.Fatalf("expected output ok, got %q", out) } } // TestRunnerRunFailureIncludesOutput runs one orchestration or CLI step. // Signature: TestRunnerRunFailureIncludesOutput(t *testing.T). // Why: keeps behavior explicit so startup/shutdown workflows remain maintainable as services evolve. func TestRunnerRunFailureIncludesOutput(t *testing.T) { r := &Runner{} out, err := r.Run(context.Background(), "sh", "-c", "echo boom >&2; exit 1") if err == nil { t.Fatalf("expected command failure") } if strings.TrimSpace(out) != "boom" { t.Fatalf("expected stderr to be preserved, got %q", out) } } // TestRunnerCommandExists runs one orchestration or CLI step. // Signature: TestRunnerCommandExists(t *testing.T). // Why: keeps behavior explicit so startup/shutdown workflows remain maintainable as services evolve. func TestRunnerCommandExists(t *testing.T) { r := &Runner{} if !r.CommandExists("sh") { t.Fatalf("expected shell command to exist") } }