* feat(cli): improve agent ergonomics * fix(cli): address code review findings - Fix nil pointer dereference in confirmDestructive when flags is nil - Deduplicate dry-run logic by delegating to dryRunExit - Remove deprecated net.Error.Temporary() call (dead since Go 1.18) - Add unit tests for resolveTasklistID and resolveCalendarID Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: resolve PR #201 conflicts and follow-ups (#201) (thanks @salmonumbrella) * fix: resolve rebase fallout for PR #201 landing (#201) (thanks @salmonumbrella) --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: Peter Steinberger <steipete@gmail.com>
33 lines
868 B
Go
33 lines
868 B
Go
package cmd
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"testing"
|
|
|
|
"github.com/steipete/gogcli/internal/outfmt"
|
|
)
|
|
|
|
func TestAgentExitCodes_JSON(t *testing.T) {
|
|
ctx := outfmt.WithMode(context.Background(), outfmt.Mode{JSON: true})
|
|
|
|
out := captureStdout(t, func() {
|
|
if err := (&AgentExitCodesCmd{}).Run(ctx); err != nil {
|
|
t.Fatalf("Run: %v", err)
|
|
}
|
|
})
|
|
|
|
var doc struct {
|
|
ExitCodes map[string]int `json:"exit_codes"`
|
|
}
|
|
if err := json.Unmarshal([]byte(out), &doc); err != nil {
|
|
t.Fatalf("unmarshal: %v (out=%q)", err, out)
|
|
}
|
|
if doc.ExitCodes["empty_results"] != emptyResultsExitCode {
|
|
t.Fatalf("expected empty_results=%d, got %d", emptyResultsExitCode, doc.ExitCodes["empty_results"])
|
|
}
|
|
if doc.ExitCodes["auth_required"] != exitCodeAuthRequired {
|
|
t.Fatalf("expected auth_required=%d, got %d", exitCodeAuthRequired, doc.ExitCodes["auth_required"])
|
|
}
|
|
}
|