Preserve flag-based artifact regeneration arguments
This commit is contained in:
@@ -15,7 +15,7 @@ func RegenerateArtifacts(ctx context.Context, args []string, out io.Writer) erro
|
||||
}
|
||||
|
||||
expanded := make([]string, 0, len(args)+5)
|
||||
if len(args) > 0 {
|
||||
if len(args) > 0 && !isCLIFlagToken(args[0]) {
|
||||
expanded = append(expanded, args[0])
|
||||
args = args[1:]
|
||||
}
|
||||
|
||||
@@ -40,6 +40,35 @@ func TestRegenerateArtifactsForwardsExactCanonicalRunArguments(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestRegenerateArtifactsForwardsSessionIDCompatibilityFlag(t *testing.T) {
|
||||
original := runCommandFn
|
||||
t.Cleanup(func() { runCommandFn = original })
|
||||
var captured []string
|
||||
runCommandFn = func(_ context.Context, args []string, _ io.Writer) error {
|
||||
captured = append([]string(nil), args...)
|
||||
return nil
|
||||
}
|
||||
|
||||
code := Execute([]string{
|
||||
"regenerate-artifacts",
|
||||
"--config", "pipeline.yml",
|
||||
"--session-id", "2026-05-03",
|
||||
"--artifacts", "session_recap",
|
||||
}, io.Discard, io.Discard)
|
||||
if code != 0 {
|
||||
t.Fatalf("Execute() code = %d, want 0", code)
|
||||
}
|
||||
want := []string{
|
||||
"--force", "--from", "extract", "--through", "analyze",
|
||||
"--config", "pipeline.yml",
|
||||
"--session-id", "2026-05-03",
|
||||
"--artifacts", "session_recap",
|
||||
}
|
||||
if !reflect.DeepEqual(captured, want) {
|
||||
t.Fatalf("forwarded args = %#v, want %#v", captured, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRegenerateArtifactsHelpDoesNotInvokeRun(t *testing.T) {
|
||||
original := runCommandFn
|
||||
t.Cleanup(func() { runCommandFn = original })
|
||||
|
||||
Reference in New Issue
Block a user