feat: пример конфига, README; чистка и тесты BuildNotifiers
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -91,3 +91,58 @@ func TestHandlerSendError(t *testing.T) {
|
||||
t.Fatalf("expected 502, got %d", rec.Code)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuildNotifiersEmpty(t *testing.T) {
|
||||
n, err := BuildNotifiers(&Config{})
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected err: %v", err)
|
||||
}
|
||||
if len(n) != 0 {
|
||||
t.Fatalf("expected empty map, got %d", len(n))
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuildNotifiersPachcaMissingURL(t *testing.T) {
|
||||
_, err := BuildNotifiers(&Config{Pachca: &ConfigPachca{}})
|
||||
if err == nil {
|
||||
t.Fatal("expected error for empty webhook_url")
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuildNotifiersEmailNoRecipients(t *testing.T) {
|
||||
_, err := BuildNotifiers(&Config{Email: &ConfigEmail{
|
||||
SMTPAddr: "smtp.example.com:587",
|
||||
From: "logger@example.com",
|
||||
To: nil,
|
||||
}})
|
||||
if err == nil {
|
||||
t.Fatal("expected error for zero recipients")
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuildNotifiersEmailBadSMTPAddr(t *testing.T) {
|
||||
_, err := BuildNotifiers(&Config{Email: &ConfigEmail{
|
||||
SMTPAddr: "no-port",
|
||||
From: "logger@example.com",
|
||||
To: []string{"a@example.com"},
|
||||
}})
|
||||
if err == nil {
|
||||
t.Fatal("expected error for smtp_addr without port")
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuildNotifiersEmailOK(t *testing.T) {
|
||||
n, err := BuildNotifiers(&Config{Email: &ConfigEmail{
|
||||
SMTPAddr: "smtp.example.com:587",
|
||||
Username: "u",
|
||||
Password: "p",
|
||||
From: "logger@example.com",
|
||||
To: []string{"a@example.com"},
|
||||
}})
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected err: %v", err)
|
||||
}
|
||||
if _, ok := n["email"]; !ok {
|
||||
t.Fatal("email notifier not built")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user