feat(cli): positional account grammar, account show, TTY remove confirm; drop whitelist flags
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+17
-10
@@ -84,8 +84,8 @@ func TestConfigList(t *testing.T) {
|
||||
|
||||
func TestAccountRemove(t *testing.T) {
|
||||
adminEnv(t)
|
||||
run(t, "account", "add", "--name", "gone", "--imap-host", "h", "--username", "u@x.com")
|
||||
if code, _, e := run(t, "account", "remove", "--name", "gone", "--yes"); code != 0 {
|
||||
run(t, "account", "add", "gone", "--imap-host", "h", "--username", "u@x.com")
|
||||
if code, _, e := run(t, "account", "remove", "gone", "--yes"); code != 0 {
|
||||
t.Fatalf("remove failed: %s", e)
|
||||
}
|
||||
_, out, _ := run(t, "account", "list")
|
||||
@@ -96,17 +96,26 @@ func TestAccountRemove(t *testing.T) {
|
||||
|
||||
func TestAccountRemoveMissing(t *testing.T) {
|
||||
adminEnv(t)
|
||||
if code, _, _ := run(t, "account", "remove", "--name", "nope", "--yes"); code == 0 {
|
||||
if code, _, _ := run(t, "account", "remove", "nope", "--yes"); code == 0 {
|
||||
t.Fatal("removing a missing account must be non-zero")
|
||||
}
|
||||
}
|
||||
|
||||
func TestAccountRemoveNoTTYNeedsYes(t *testing.T) {
|
||||
adminEnv(t)
|
||||
run(t, "account", "add", "keep", "--imap-host", "h", "--username", "u@x.com")
|
||||
// Under `go test`, stdin is not a TTY, so without --yes this must refuse.
|
||||
code, _, errOut := run(t, "account", "remove", "keep")
|
||||
if code != 2 || !strings.Contains(errOut, "--yes") {
|
||||
t.Fatalf("non-TTY remove without --yes must refuse: code=%d err=%q", code, errOut)
|
||||
}
|
||||
}
|
||||
|
||||
func TestAccountEditPartialPreservesOtherFields(t *testing.T) {
|
||||
db := adminEnv(t)
|
||||
run(t, "account", "add", "--name", "ed", "--mode", "RO",
|
||||
run(t, "account", "add", "ed", "--mode", "RO",
|
||||
"--imap-host", "imap.x.com", "--username", "u@x.com", "--password", "orig")
|
||||
// Edit only mode + add SMTP; imap-host, username, password must be preserved.
|
||||
if code, _, e := run(t, "account", "edit", "--name", "ed", "--mode", "RW",
|
||||
if code, _, e := run(t, "account", "edit", "ed", "--mode", "RW",
|
||||
"--smtp-host", "smtp.x.com", "--smtp-port", "587", "--smtp-security", "starttls"); code != 0 {
|
||||
t.Fatalf("edit failed: %s", e)
|
||||
}
|
||||
@@ -217,10 +226,8 @@ func TestAuditListCoreRenders(t *testing.T) {
|
||||
|
||||
func TestAccountEditFromValidationRejectsMalformed(t *testing.T) {
|
||||
adminEnv(t)
|
||||
// Seed an account so the failure is from --from validation, not a missing account.
|
||||
run(t, "account", "add", "--name", "valacc", "--imap-host", "imap.x.com", "--username", "u@x.com")
|
||||
// A malformed --from value must be rejected with exit code 2 before touching the account.
|
||||
code, _, errStr := run(t, "account", "edit", "--name", "valacc", "--from", "not an address")
|
||||
run(t, "account", "add", "valacc", "--imap-host", "imap.x.com", "--username", "u@x.com")
|
||||
code, _, errStr := run(t, "account", "edit", "valacc", "--from", "not an address")
|
||||
if code != 2 {
|
||||
t.Fatalf("expected exit code 2 for malformed --from, got %d (stderr: %q)", code, errStr)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user