package execxquality import ( "bytes" "context" "log" "strings" "testing" "scm.bstein.dev/bstein/ananke/internal/execx" ) // TestRunnerDryRun runs one orchestration or CLI step. // Signature: TestRunnerDryRun(t *testing.T). // Why: keeps dry-run logging behavior explicit after moving runner tests into // the top-level testing module. func TestRunnerDryRun(t *testing.T) { var buf bytes.Buffer runner := &execx.Runner{ DryRun: true, Logger: log.New(&buf, "", 0), } out, err := runner.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()) } } // TestRunnerInjectsKubeconfigEnv runs one orchestration or CLI step. // Signature: TestRunnerInjectsKubeconfigEnv(t *testing.T). // Why: keeps kubeconfig environment propagation covered from the split testing module. func TestRunnerInjectsKubeconfigEnv(t *testing.T) { runner := &execx.Runner{Kubeconfig: "/tmp/test-kubeconfig"} out, err := runner.Run(context.Background(), "sh", "-c", "printf %s \"$KUBECONFIG\"") if err != nil { t.Fatalf("runner command failed: %v", err) } if strings.TrimSpace(out) != "/tmp/test-kubeconfig" { t.Fatalf("expected kubeconfig env to propagate, got %q", out) } } // TestRunnerNilLoggerHook runs one orchestration or CLI step. // Signature: TestRunnerNilLoggerHook(t *testing.T). // Why: keeps the nil-logger no-op branch covered without reintroducing same-package tests. func TestRunnerNilLoggerHook(t *testing.T) { execx.TestHookLogf(&execx.Runner{}, "hello %s", "world") }