Skip to content

Commit

Permalink
fix: asset filter query test (#132)
Browse files Browse the repository at this point in the history
* fix: specify sql query order

* refactor: update test

* docs: update comment in data filter test
  • Loading branch information
scortier authored May 20, 2022
1 parent f4c39a5 commit 2710ee0
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions store/postgres/asset_repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,24 +170,24 @@ func (r *AssetRepositoryTestSuite) TestBuildFilterQuery() {
expectedQuery: `(data->'landscape'->'properties'->>'project-id' ILIKE $1 OR description ILIKE $2)`,
},
{
// NOTE: Cannot have more than one key in map because golang's map does not guarantee order thus producing
// inconsistent test.
description: "should return sql query with asset's data fields filter",
config: asset.Filter{
Data: map[string]string{
"entity": "odpf",
"country": "th",
"entity": "odpf",
},
},
expectedQuery: `data->>'entity' = 'odpf' AND data->>'country' = 'th'`,
expectedQuery: `data->>'entity' = 'odpf'`,
},
{
description: "should return sql query with asset's nested data fields filter",
config: asset.Filter{
Data: map[string]string{
"landscape.properties.project-id": "compass_001",
"country": "vn",
},
},
expectedQuery: `data->'landscape'->'properties'->>'project-id' = 'compass_001' AND data->>'country' = 'vn'`,
expectedQuery: `data->'landscape'->'properties'->>'project-id' = 'compass_001'`,
},
}

Expand Down

0 comments on commit 2710ee0

Please sign in to comment.