-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
de2b563
commit db1f891
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} |