mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-24 01:38:50 +02:00
[BREAKING] changed notification config format, support multiple notification providers, support webhook and markdown style notification
This commit is contained in:
52
internal/notif/gotify_test.go
Normal file
52
internal/notif/gotify_test.go
Normal file
@@ -0,0 +1,52 @@
|
||||
package notif
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/yusing/go-proxy/internal/utils"
|
||||
. "github.com/yusing/go-proxy/internal/utils/testing"
|
||||
)
|
||||
|
||||
func TestGotifyValidation(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
newGotify := Providers[ProviderGotify]
|
||||
|
||||
t.Run("valid", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, err := newGotify(map[string]any{
|
||||
"name": "test",
|
||||
"url": "https://example.com",
|
||||
"token": "token",
|
||||
})
|
||||
ExpectNoError(t, err)
|
||||
})
|
||||
|
||||
t.Run("missing url", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, err := newGotify(map[string]any{
|
||||
"name": "test",
|
||||
"token": "token",
|
||||
})
|
||||
ExpectError(t, utils.ErrValidationError, err)
|
||||
})
|
||||
|
||||
t.Run("missing token", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, err := newGotify(map[string]any{
|
||||
"name": "test",
|
||||
"url": "https://example.com",
|
||||
})
|
||||
ExpectError(t, utils.ErrValidationError, err)
|
||||
})
|
||||
|
||||
t.Run("invalid url", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, err := newGotify(map[string]any{
|
||||
"name": "test",
|
||||
"url": "example.com",
|
||||
"token": "token",
|
||||
})
|
||||
ExpectError(t, utils.ErrValidationError, err)
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user