Skip to content

Commit

Permalink
Update to latest gocommon which changes contact ql conversion to ES
Browse files Browse the repository at this point in the history
  • Loading branch information
rowanseymour committed Jul 15, 2024
1 parent 206ab72 commit 4bdd3bf
Show file tree
Hide file tree
Showing 5 changed files with 527 additions and 333 deletions.
20 changes: 18 additions & 2 deletions contactql/es/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func TestElasticQuery(t *testing.T) {

ny, _ := time.LoadLocation("America/New_York")

for _, tc := range tcs {
for i, tc := range tcs {
testName := fmt.Sprintf("test '%s' for query '%s'", tc.Description, tc.Query)

redactionPolicy := envs.RedactionPolicyNone
Expand All @@ -99,6 +99,22 @@ func TestElasticQuery(t *testing.T) {
asJSON, err := jsonx.Marshal(query)
require.NoError(t, err)

test.AssertEqualJSON(t, tc.Elastic, asJSON, "elastic mismatch in %s", testName)
// clone test case and populate with actual values
actual := tc
actual.Elastic = asJSON

if !test.UpdateSnapshots {
test.AssertEqualJSON(t, tc.Elastic, actual.Elastic, "elastic mismatch in %s", testName)
} else {
tcs[i] = actual
}
}

if test.UpdateSnapshots {
actualJSON, err := jsonx.MarshalPretty(tcs)
require.NoError(t, err)

err = os.WriteFile("testdata/to_query.json", actualJSON, 0666)
require.NoError(t, err)
}
}
Loading

0 comments on commit 4bdd3bf

Please sign in to comment.