diff --git a/internal/cli/app.go b/internal/cli/app.go index 21a5e1e..0b58d50 100644 --- a/internal/cli/app.go +++ b/internal/cli/app.go @@ -10,7 +10,7 @@ type App struct { store secretstore.Store } -func NewApp(_ ...any) *App { +func NewApp() *App { return &App{} } diff --git a/internal/cli/app_test.go b/internal/cli/app_test.go index 3af3df8..19b263a 100644 --- a/internal/cli/app_test.go +++ b/internal/cli/app_test.go @@ -5,6 +5,8 @@ import ( "testing" ) +var _ func() *App = NewApp + func TestAppRunRejectsUnknownCommand(t *testing.T) { app := NewApp() diff --git a/internal/secretstore/store_test.go b/internal/secretstore/store_test.go index 4ac06df..0ffc95d 100644 --- a/internal/secretstore/store_test.go +++ b/internal/secretstore/store_test.go @@ -3,9 +3,33 @@ package secretstore import "testing" func TestCredentialValidateRequiresAllFields(t *testing.T) { - cred := Credential{Host: "imap.example.com", Username: "alice"} + tests := []struct { + name string + cred Credential + }{ + { + name: "missing host", + cred: Credential{Username: "alice", Password: "secret"}, + }, + { + name: "missing username", + cred: Credential{Host: "imap.example.com", Password: "secret"}, + }, + { + name: "missing password", + cred: Credential{Host: "imap.example.com", Username: "alice"}, + }, + { + name: "whitespace only fields", + cred: Credential{Host: " \t ", Username: "\n", Password: " "}, + }, + } - if err := cred.Validate(); err == nil { - t.Fatal("expected validation error when password is missing") + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if err := tt.cred.Validate(); err == nil { + t.Fatal("expected validation error when a required field is missing") + } + }) } }