mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-25 02:09:01 +02:00
refactor: notifications
This commit is contained in:
@@ -25,8 +25,9 @@ func TestNotificationConfig(t *testing.T) {
|
||||
},
|
||||
expected: &Webhook{
|
||||
ProviderBase: ProviderBase{
|
||||
Name: "test",
|
||||
URL: "https://example.com",
|
||||
Name: "test",
|
||||
URL: "https://example.com",
|
||||
Format: LogFormatMarkdown,
|
||||
},
|
||||
Template: "discord",
|
||||
Method: http.MethodPost,
|
||||
@@ -43,12 +44,32 @@ func TestNotificationConfig(t *testing.T) {
|
||||
"provider": "gotify",
|
||||
"url": "https://example.com",
|
||||
"token": "token",
|
||||
"format": "plain",
|
||||
},
|
||||
expected: &GotifyClient{
|
||||
ProviderBase: ProviderBase{
|
||||
Name: "test",
|
||||
URL: "https://example.com",
|
||||
Token: "token",
|
||||
Name: "test",
|
||||
URL: "https://example.com",
|
||||
Token: "token",
|
||||
Format: LogFormatPlain,
|
||||
},
|
||||
},
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "default_format",
|
||||
cfg: map[string]any{
|
||||
"name": "test",
|
||||
"provider": "gotify",
|
||||
"token": "token",
|
||||
"url": "https://example.com",
|
||||
},
|
||||
expected: &GotifyClient{
|
||||
ProviderBase: ProviderBase{
|
||||
Name: "test",
|
||||
URL: "https://example.com",
|
||||
Token: "token",
|
||||
Format: LogFormatMarkdown,
|
||||
},
|
||||
},
|
||||
wantErr: false,
|
||||
@@ -62,6 +83,16 @@ func TestNotificationConfig(t *testing.T) {
|
||||
},
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "invalid_format",
|
||||
cfg: map[string]any{
|
||||
"name": "test",
|
||||
"provider": "webhook",
|
||||
"url": "https://example.com",
|
||||
"format": "invalid",
|
||||
},
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "missing_url",
|
||||
cfg: map[string]any{
|
||||
|
||||
Reference in New Issue
Block a user