Skip to content

Commit

Permalink
Extend test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
Luis Fonseca committed Sep 2, 2020
1 parent de49229 commit 8557c5a
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -519,17 +519,31 @@ func TestDataSizeValidation(t *testing.T) {
err := client.Trigger("channel", "event", data)

assert.EqualError(t, err, "Event payload exceeded maximum size (20481 bytes is too much)")

err = client.TriggerBatch([]Event{
{"channel", "event", data, nil},
})
assert.EqualError(t, err, "Data of the event #0 in batch, exceeded maximum size (20481 bytes is too much)")
}

func TestDataSizeOverridenValidation(t *testing.T) {
client := Client{AppID: "id", Key: "key", Secret: "secret", OverrideMaxMessagePayloadKB: 80}
data := strings.Repeat("a", 81920)
err := client.Trigger("channel", "event", data)
assert.NotContains(t, err.Error(), "\"Event payload exceeded maximum size (81921 bytes is too much)")
assert.NotContains(t, err.Error(), "\"Event payload exceeded maximum size (81920 bytes is too much)")
err = client.TriggerBatch([]Event{
{"channel", "event", data, nil},
})
assert.NotContains(t, err.Error(), "Data of the event #0 in batch, exceeded maximum size (81920 bytes is too much)")

data = strings.Repeat("a", 81921)
err = client.Trigger("channel", "event", data)
assert.EqualError(t, err, "Event payload exceeded maximum size (81921 bytes is too much)")

err = client.TriggerBatch([]Event{
{"channel", "event", data, nil},
})
assert.EqualError(t, err, "Data of the event #0 in batch, exceeded maximum size (81921 bytes is too much)")
}

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

0 comments on commit 8557c5a

Please sign in to comment.