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

Commit

Permalink
Add test for DataMall unavailable message
Browse files Browse the repository at this point in the history
  • Loading branch information
yi-jiayu committed Jan 17, 2019
1 parent 1ba082e commit 64aedb1
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions eta_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,29 @@ func TestEtaMessage(t *testing.T) {
if actual != expected {
t.Fail()
}

t.Run("when datamall returns an error", func(t *testing.T) {
bot := &BusEtaBot{
Datamall: MockDatamall{
BusArrival: datamall.BusArrival{},
Error: datamall.Error{StatusCode: 503},
},
NowFunc: func() time.Time {
return time.Time{}
},
BusStops: MockBusStops{
BusStop: nil,
},
}

actual, err := EtaMessageText(bot, "81111", nil)
if err != nil && err != errNotFound {
t.Fatal(err)
}

expected := "Oh no! The LTA DataMall API that Bus Eta Bot relies on appears to be down at the moment (it returned HTTP status code 503)."
assert.Equal(t, expected, actual)
})
}

func TestEtaMessageReplyMarkup(t *testing.T) {
Expand Down

0 comments on commit 64aedb1

Please sign in to comment.