fix: tighten config and update error handling
This commit is contained in:
@@ -67,6 +67,9 @@ func Validate(cfg domain.Config) error {
|
||||
if strings.TrimSpace(cfg.Gitea.Org) == "" {
|
||||
return errors.New("gitea org is required")
|
||||
}
|
||||
if strings.TrimSpace(cfg.Gitea.Username) == "" {
|
||||
return errors.New("gitea username is required")
|
||||
}
|
||||
if cfg.Gitea.AuthType != AuthPassword && cfg.Gitea.AuthType != AuthToken {
|
||||
return errors.New("authType must be password or token")
|
||||
}
|
||||
|
||||
@@ -62,6 +62,11 @@ func TestValidateRejectsMissingConnectionFields(t *testing.T) {
|
||||
}
|
||||
|
||||
cfg.Gitea.Org = "skills"
|
||||
if err := Validate(cfg); err == nil {
|
||||
t.Fatal("Validate returned nil error without username")
|
||||
}
|
||||
|
||||
cfg.Gitea.Username = "alice"
|
||||
if err := Validate(cfg); err != nil {
|
||||
t.Fatalf("Validate returned error for valid config: %v", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user