Skip to content

Commit

Permalink
Add check for invalid to existing Write_Simple test
Browse files Browse the repository at this point in the history
  • Loading branch information
colmsnowplow committed Jul 1, 2024
1 parent b070fb3 commit d499dc7
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion pkg/target/http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,11 @@ func TestHTTPWrite_Simple(t *testing.T) {
wg.Done()
}

messages := testutil.GetTestMessages(25, `{"message": "Hello Server!!"}`, ackFunc)
goodMessages := testutil.GetTestMessages(25, `{"message": "Hello Server!!"}`, ackFunc)
badMessages := testutil.GetTestMessages(3, `{"message": "Hello Server!!"`, ackFunc) // invalids

messages := append(goodMessages, badMessages...)

wg.Add(25)
writeResult, err1 := target.Write(messages)

Expand All @@ -374,6 +378,12 @@ func TestHTTPWrite_Simple(t *testing.T) {
assert.Equal(`[{"message":"Hello Server!!"}]`, string(result))
}

assert.Equal(3, len(writeResult.Invalid)) // invalids went to the right place
for _, msg := range writeResult.Invalid {
// Check all invalids have error as expected
assert.Regexp("Message can't be parsed as valid JSON: .*", msg.GetError().Error())
}

assert.Equal(int64(25), ackOps)
})
}
Expand Down

0 comments on commit d499dc7

Please sign in to comment.