Skip to content

Commit

Permalink
assert error is returned when attribute column not returned in result…
Browse files Browse the repository at this point in the history
… set
  • Loading branch information
Grandys committed Aug 25, 2024
1 parent e9a3cce commit 43abd17
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions receiver/sqlqueryreceiver/logs_receiver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,24 @@ func TestLogsQueryReceiver_Collect(t *testing.T) {
"Observed timestamps of all log records collected in a single scrape should be equal",
)
}

func TestLogsQueryReceiver_MissingColumnInResultSetForAttributeColumn(t *testing.T) {
fakeClient := &sqlquery.FakeDBClient{
StringMaps: [][]sqlquery.StringMap{
{{"col1": "42"}},
},
}
queryReceiver := logsQueryReceiver{
client: fakeClient,
query: sqlquery.Query{
Logs: []sqlquery.LogsCfg{
{
BodyColumn: "col1",
AttributeColumns: []string{"expected_column"},
},
},
},
}
_, err := queryReceiver.collect(context.Background())
assert.ErrorContains(t, err, "rowToLog: attribute_column not found: 'expected_column'")
}

0 comments on commit 43abd17

Please sign in to comment.