Skip to content
This repository has been archived by the owner on May 29, 2024. It is now read-only.

Commit

Permalink
Add Unit test for telegram client
Browse files Browse the repository at this point in the history
  • Loading branch information
richardgreg committed Feb 20, 2024
1 parent 3bb3585 commit 703355a
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions internal/client/telegram_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package client_test

import (
"testing"

"github.com/stretchr/testify/assert"

"github.com/base-org/pessimism/internal/client"
"github.com/base-org/pessimism/internal/core"
)

func TestTelegramResponseToAlertResponse(t *testing.T) {
// Test case for a successful Telegram response
testTelegramSuccess := &client.TelegramAPIResponse{
Ok: true,
Result: nil,
Error: "",
}

// Test case for a failed Telegram response
testTelegramFailure := &client.TelegramAPIResponse{
Ok: false,
Error: "error message",
}

resSuc := testTelegramSuccess.ToAlertResponse()
resFail := testTelegramFailure.ToAlertResponse()

// Assert that the success case is correctly interpreted
assert.Equal(t, core.SuccessStatus, resSuc.Status)
assert.Equal(t, "Message sent successfully", resSuc.Message)

// Assert that the failure case is correctly interpreted
assert.Equal(t, core.FailureStatus, resFail.Status)
assert.Equal(t, "error message", resFail.Message)
}

0 comments on commit 703355a

Please sign in to comment.