* 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>
44 lines
1.0 KiB
Go
44 lines
1.0 KiB
Go
package cmd
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"testing"
|
|
)
|
|
|
|
func TestConfirmDestructiveForce(t *testing.T) {
|
|
flags := &RootFlags{Force: true}
|
|
if err := confirmDestructive(context.TODO(), flags, "delete"); err != nil {
|
|
t.Fatalf("expected no error, got %v", err)
|
|
}
|
|
}
|
|
|
|
func TestConfirmDestructiveNoInput(t *testing.T) {
|
|
flags := &RootFlags{NoInput: true}
|
|
err := confirmDestructive(context.TODO(), flags, "delete")
|
|
if err == nil {
|
|
t.Fatalf("expected error")
|
|
}
|
|
var exitErr *ExitError
|
|
if !errors.As(err, &exitErr) || exitErr.Code != 2 {
|
|
t.Fatalf("expected ExitError code 2, got %#v", err)
|
|
}
|
|
}
|
|
|
|
func TestConfirmDestructiveDryRun(t *testing.T) {
|
|
flags := &RootFlags{DryRun: true}
|
|
out := captureStdout(t, func() {
|
|
err := confirmDestructive(context.TODO(), flags, "delete something")
|
|
if err == nil {
|
|
t.Fatalf("expected early exit error")
|
|
}
|
|
var exitErr *ExitError
|
|
if !errors.As(err, &exitErr) || exitErr.Code != 0 {
|
|
t.Fatalf("expected ExitError code 0, got %#v", err)
|
|
}
|
|
})
|
|
if out == "" {
|
|
t.Fatalf("expected output")
|
|
}
|
|
}
|