refactor: remove redundant internal test functions from cli_internal_test.go
- Remove cancel reason tests (covered by blackbox tests) - Remove codex exec args tests (covered by blackbox tests) - Update emitter test comment for clarity
This commit is contained in:
parent
af0da6b822
commit
cb96fb58eb
1 changed files with 1 additions and 78 deletions
|
|
@ -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{}
|
||||
|
|
|
|||
Loading…
Reference in a new issue