Skip to content

Commit

Permalink
Add test to assert source metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
Guillem committed Feb 2, 2024
1 parent 21510c7 commit fab40ee
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,18 @@ func TestSource_Integration_RestartPartial(t *testing.T) {
testSourceIntegrationRead(ctx, is, cfgMap, lastPosition, wantRecs, false)
}

const testAppId = "id-1234"

func generateRabbitmqMsgs(from, to int) []amqp091.Publishing {
var msgs []amqp091.Publishing

for i := from; i <= to; i++ {
msg := amqp091.Publishing{
MessageId: fmt.Sprintf("test-msg-id-%d", i),
ContentType: "text/plain",
// setting testAppId asserts that the metadata is being set
AppId: testAppId,

Body: []byte(fmt.Sprintf("test-payload-%d", i)),
}

Expand Down Expand Up @@ -137,6 +144,9 @@ func testSourceIntegrationRead(
wantPayload := string(wantRecord.Body)
is.Equal(wantPayload, recPayload)

is.Equal(wantRecord.MessageId, string(rec.Key.Bytes()))
is.Equal(testAppId, rec.Metadata["rabbitmq.appId"])

positions = append(positions, rec.Position)
}

Expand Down

0 comments on commit fab40ee

Please sign in to comment.