diff --git a/apps/node/internal/adapters/cli/cli_internal_test.go b/apps/node/internal/adapters/cli/cli_internal_test.go index ad75bce..2163842 100644 --- a/apps/node/internal/adapters/cli/cli_internal_test.go +++ b/apps/node/internal/adapters/cli/cli_internal_test.go @@ -3,89 +3,12 @@ package cli import ( "context" "errors" - "io" "strings" "testing" "iop/apps/node/internal/runtime" - "iop/packages/config" ) -// --- cancel reason tests --- - -func TestCancelEventForContext_DeadlineMapsToTimeout(t *testing.T) { - ctx, cancel := context.WithTimeout(context.Background(), 0) - defer cancel() - <-ctx.Done() - got := cancelEventForContext(ctx.Err()) - if got != "timeout" { - t.Fatalf("expected 'timeout', got %q", got) - } -} - -func TestCancelEventForContext_CanceledMapsToUserCancel(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - cancel() - <-ctx.Done() - got := cancelEventForContext(ctx.Err()) - if got != "user-cancel" { - t.Fatalf("expected 'user-cancel', got %q", got) - } -} - -func TestCancelEventForContext_NilError(t *testing.T) { - got := cancelEventForContext(nil) - if got != "context-done" { - t.Fatalf("expected 'context-done', got %q", got) - } -} - -func TestCancelEventForContext_SiblingError(t *testing.T) { - type customErr struct{ error } - got := cancelEventForContext(customErr{io.EOF}) - if got != "context-done" { - t.Fatalf("expected 'context-done', got %q", got) - } -} - -// --- codex exec args tests --- - -func TestCodexExecArgs_NoSessionUsesProfileArgs(t *testing.T) { - profile := config.CLIProfileConf{ - Command: "codex", - Args: []string{"exec", "--json"}, - } - - args := codexExecArgs(profile, "", "hello prompt") - expected := []string{"exec", "--json", "hello prompt"} - if len(args) != len(expected) { - t.Fatalf("expected %d args, got %d: %v", len(expected), len(args), args) - } - for i, v := range expected { - if args[i] != v { - t.Errorf("args[%d]: expected %q, got %q", i, v, args[i]) - } - } -} - -func TestCodexExecArgs_WithSessionUsesResumeArgs(t *testing.T) { - profile := config.CLIProfileConf{ - Args: []string{"exec", "--json"}, - ResumeArgs: []string{"exec", "resume", "--color", "never"}, - } - - args := codexExecArgs(profile, "session-abc", "hello prompt") - expected := []string{"exec", "resume", "--color", "never", "session-abc", "hello prompt"} - if len(args) != len(expected) { - t.Fatalf("expected %d args, got %d: %v", len(expected), len(args), args) - } - for i, v := range expected { - if args[i] != v { - t.Errorf("args[%d]: expected %q, got %q", i, v, args[i]) - } - } -} - // --- driveJSONLines tests --- type testSink struct { @@ -270,7 +193,7 @@ func TestDriveJSONLines_OutputTokensCountedForDeltaOnly(t *testing.T) { } } -// --- emitter unit tests (edge cases not covered by blackbox tests) --- +// --- emitter edge case tests (not covered by blackbox tests) --- func TestStreamJSONEmitter_SkipsNonAssistantRoles(t *testing.T) { e := streamJSONEmitter{}