Skip to content

Commit

Permalink
Merge pull request #1275 from nyaruka/latest_gocommon
Browse files Browse the repository at this point in the history
Update to latest gocommon which changes contactql conversion to ES
  • Loading branch information
rowanseymour authored Jul 15, 2024
2 parents 206ab72 + 4bdd3bf commit 0c0a517
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 0c0a517

Please sign in to comment.