[BREAKING] changed notification config format, support multiple notification providers, support webhook and markdown style notification

This commit is contained in:
yusing
2024-11-30 06:44:49 +08:00
parent fb9de4c4ad
commit 25eeabb9f9
12 changed files with 522 additions and 99 deletions

View 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)
})
}