FEATURE (notifiers): Change testing notifier from Telegram to webhook

This commit is contained in:
Rostislav Dugin
2026-03-21 12:26:57 +03:00
parent f60f677351
commit a17ea2f3e2
4 changed files with 8 additions and 29 deletions

View File

@@ -304,9 +304,6 @@ jobs:
TEST_MARIADB_114_PORT=33114 TEST_MARIADB_114_PORT=33114
TEST_MARIADB_118_PORT=33118 TEST_MARIADB_118_PORT=33118
TEST_MARIADB_120_PORT=33120 TEST_MARIADB_120_PORT=33120
# testing Telegram
TEST_TELEGRAM_BOT_TOKEN=${{ secrets.TEST_TELEGRAM_BOT_TOKEN }}
TEST_TELEGRAM_CHAT_ID=${{ secrets.TEST_TELEGRAM_CHAT_ID }}
# supabase # supabase
TEST_SUPABASE_HOST=${{ secrets.TEST_SUPABASE_HOST }} TEST_SUPABASE_HOST=${{ secrets.TEST_SUPABASE_HOST }}
TEST_SUPABASE_PORT=${{ secrets.TEST_SUPABASE_PORT }} TEST_SUPABASE_PORT=${{ secrets.TEST_SUPABASE_PORT }}

View File

@@ -45,9 +45,6 @@ TEST_MINIO_PORT=9000
TEST_MINIO_CONSOLE_PORT=9001 TEST_MINIO_CONSOLE_PORT=9001
# testing NAS # testing NAS
TEST_NAS_PORT=7006 TEST_NAS_PORT=7006
# testing Telegram
TEST_TELEGRAM_BOT_TOKEN=
TEST_TELEGRAM_CHAT_ID=
# testing Azure Blob Storage # testing Azure Blob Storage
TEST_AZURITE_BLOB_PORT=10000 TEST_AZURITE_BLOB_PORT=10000
# supabase # supabase

View File

@@ -109,10 +109,6 @@ type EnvVariables struct {
CloudflareTurnstileSecretKey string `env:"CLOUDFLARE_TURNSTILE_SECRET_KEY"` CloudflareTurnstileSecretKey string `env:"CLOUDFLARE_TURNSTILE_SECRET_KEY"`
CloudflareTurnstileSiteKey string `env:"CLOUDFLARE_TURNSTILE_SITE_KEY"` CloudflareTurnstileSiteKey string `env:"CLOUDFLARE_TURNSTILE_SITE_KEY"`
// testing Telegram
TestTelegramBotToken string `env:"TEST_TELEGRAM_BOT_TOKEN"`
TestTelegramChatID string `env:"TEST_TELEGRAM_CHAT_ID"`
// testing Supabase // testing Supabase
TestSupabaseHost string `env:"TEST_SUPABASE_HOST"` TestSupabaseHost string `env:"TEST_SUPABASE_HOST"`
TestSupabasePort string `env:"TEST_SUPABASE_PORT"` TestSupabasePort string `env:"TEST_SUPABASE_PORT"`
@@ -365,15 +361,6 @@ func loadEnvVariables() {
os.Exit(1) os.Exit(1)
} }
if env.TestTelegramBotToken == "" {
log.Error("TEST_TELEGRAM_BOT_TOKEN is empty")
os.Exit(1)
}
if env.TestTelegramChatID == "" {
log.Error("TEST_TELEGRAM_CHAT_ID is empty")
os.Exit(1)
}
} }
log.Info("Environment variables loaded successfully!") log.Info("Environment variables loaded successfully!")

View File

@@ -9,7 +9,6 @@ import (
"github.com/google/uuid" "github.com/google/uuid"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"databasus-backend/internal/config"
audit_logs "databasus-backend/internal/features/audit_logs" audit_logs "databasus-backend/internal/features/audit_logs"
discord_notifier "databasus-backend/internal/features/notifiers/models/discord" discord_notifier "databasus-backend/internal/features/notifiers/models/discord"
email_notifier "databasus-backend/internal/features/notifiers/models/email_notifier" email_notifier "databasus-backend/internal/features/notifiers/models/email_notifier"
@@ -159,7 +158,7 @@ func Test_SendTestNotificationDirect_NotificationSent(t *testing.T) {
router := createRouter() router := createRouter()
workspace := workspaces_testing.CreateTestWorkspace("Test Workspace", owner, router) workspace := workspaces_testing.CreateTestWorkspace("Test Workspace", owner, router)
notifier := createTelegramNotifier(workspace.ID) notifier := createWebhookNotifier(workspace.ID)
response := test_utils.MakePostRequest( response := test_utils.MakePostRequest(
t, router, "/api/v1/notifiers/direct-test", "Bearer "+owner.Token, *notifier, http.StatusOK, t, router, "/api/v1/notifiers/direct-test", "Bearer "+owner.Token, *notifier, http.StatusOK,
@@ -174,7 +173,7 @@ func Test_SendTestNotificationExisting_NotificationSent(t *testing.T) {
router := createRouter() router := createRouter()
workspace := workspaces_testing.CreateTestWorkspace("Test Workspace", owner, router) workspace := workspaces_testing.CreateTestWorkspace("Test Workspace", owner, router)
notifier := createTelegramNotifier(workspace.ID) notifier := createWebhookNotifier(workspace.ID)
var savedNotifier Notifier var savedNotifier Notifier
test_utils.MakePostRequestAndUnmarshal( test_utils.MakePostRequestAndUnmarshal(
@@ -1252,15 +1251,14 @@ func createNewNotifier(workspaceID uuid.UUID) *Notifier {
} }
} }
func createTelegramNotifier(workspaceID uuid.UUID) *Notifier { func createWebhookNotifier(workspaceID uuid.UUID) *Notifier {
env := config.GetEnv()
return &Notifier{ return &Notifier{
WorkspaceID: workspaceID, WorkspaceID: workspaceID,
Name: "Test Telegram Notifier " + uuid.New().String(), Name: "Test Webhook Notifier " + uuid.New().String(),
NotifierType: NotifierTypeTelegram, NotifierType: NotifierTypeWebhook,
TelegramNotifier: &telegram_notifier.TelegramNotifier{ WebhookNotifier: &webhook_notifier.WebhookNotifier{
BotToken: env.TestTelegramBotToken, WebhookURL: "https://databasus.com",
TargetChatID: env.TestTelegramChatID, WebhookMethod: webhook_notifier.WebhookMethodGET,
}, },
} }
} }