Skip to content

Commit

Permalink
Add telegram test
Browse files Browse the repository at this point in the history
  • Loading branch information
ahobsonsayers committed Oct 8, 2024
1 parent de2b563 commit db1f891
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions cmd/twitchets/notification/telegram_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package notification_test

import (
"os"
"strconv"
"testing"

"github.com/ahobsonsayers/twitchets/cmd/twitchets/notification"
"github.com/ahobsonsayers/twitchets/test/testutils"
"github.com/joho/godotenv"
"github.com/stretchr/testify/require"
)

func TestTelegramSendTicketMessage(t *testing.T) {
testutils.SkipIfCI(t, "No env set in CI. Fix")

_ = godotenv.Load(testutils.ProjectDirectoryJoin(t, ".env"))

telegramAPIKey := os.Getenv("TELEGRAM_API_KEY")
require.NotEmpty(t, telegramAPIKey, "TELEGRAM_API_KEY is not set")

telegramChatIdString := os.Getenv("TELEGRAM_CHAT_ID")
require.NotEmpty(t, telegramChatIdString, "TELEGRAM_CHAT_ID is not set")

telegramChatId, err := strconv.Atoi(telegramChatIdString)
require.NoError(t, err, "TELEGRAM_CHAT_ID is not an integer")

client, err := notification.NewTelegramClient(notification.TelegramConfig{
APIToken: telegramAPIKey,
ChatId: telegramChatId,
})
require.NoError(t, err)

ticket := testNotificationTicket()
err = client.SendTicketNotification(ticket)
require.NoError(t, err)
}

0 comments on commit db1f891

Please sign in to comment.