* 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>
46 lines
1.1 KiB
Go
46 lines
1.1 KiB
Go
package cmd
|
|
|
|
import (
|
|
"encoding/json"
|
|
"testing"
|
|
)
|
|
|
|
func TestSplitCommandPath_SplitsWhitespaceWithinArgs(t *testing.T) {
|
|
got := splitCommandPath([]string{" drive ls ", " "})
|
|
want := []string{"drive", "ls"}
|
|
if len(got) != len(want) {
|
|
t.Fatalf("len mismatch: got=%v want=%v", got, want)
|
|
}
|
|
for i := range want {
|
|
if got[i] != want[i] {
|
|
t.Fatalf("unexpected token at %d: got=%q want=%q", i, got[i], want[i])
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestExecute_Schema_QuotedCommandPathToken(t *testing.T) {
|
|
out := captureStdout(t, func() {
|
|
_ = captureStderr(t, func() {
|
|
if err := Execute([]string{"schema", "drive ls"}); err != nil {
|
|
t.Fatalf("Execute: %v", err)
|
|
}
|
|
})
|
|
})
|
|
|
|
var doc struct {
|
|
Command struct {
|
|
Name string `json:"name"`
|
|
Path string `json:"path"`
|
|
} `json:"command"`
|
|
}
|
|
if err := json.Unmarshal([]byte(out), &doc); err != nil {
|
|
t.Fatalf("unmarshal: %v out=%q", err, out)
|
|
}
|
|
if doc.Command.Name != "ls" {
|
|
t.Fatalf("expected command name ls, got %q", doc.Command.Name)
|
|
}
|
|
if doc.Command.Path == "" {
|
|
t.Fatalf("expected non-empty command path")
|
|
}
|
|
}
|