package main import ( "io" "testing" ) // A bad PR reference must fail the command (so main exits non-zero) rather than // return nil. Parsing rejects the ref before any Vault/Gitea call, so this stays // hermetic. func TestExecuteBadRefErrors(t *testing.T) { cmd := newRootCmd() cmd.SetArgs([]string{"--once", "not-a-ref"}) cmd.SetOut(io.Discard) cmd.SetErr(io.Discard) if err := cmd.Execute(); err == nil { t.Fatal("Execute() = nil, want error for a bad PR reference") } } // No arguments is also an error (nothing to watch). func TestExecuteNoArgsErrors(t *testing.T) { cmd := newRootCmd() cmd.SetArgs(nil) cmd.SetOut(io.Discard) cmd.SetErr(io.Discard) if err := cmd.Execute(); err == nil { t.Fatal("Execute() = nil, want error when no PR references are given") } }