Skip to content

Commit

Permalink
checkJSONValue: error on empty results
Browse files Browse the repository at this point in the history
  • Loading branch information
serprex committed Jan 31, 2024
1 parent a0117e5 commit 6121541
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 4 additions & 0 deletions flow/e2e/bigquery/peer_flow_bq_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ func (s PeerFlowE2ETestSuiteBQ) checkJSONValue(tableName, colName, fieldName, va
return fmt.Errorf("json value check failed: %v", err)
}

if len(res.Records) == 0 {
return fmt.Errorf("bad json: empty result set from %s", tableName)
}

jsonVal := res.Records[0][0].Value
if jsonVal != value {
return fmt.Errorf("bad json value in field %s of column %s: %v. expected: %v", fieldName, colName, jsonVal, value)
Expand Down
8 changes: 5 additions & 3 deletions flow/e2e/snowflake/qrep_flow_sf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ func (s PeerFlowE2ETestSuiteSF) setupSourceTable(tableName string, numRows int)
}

func (s PeerFlowE2ETestSuiteSF) checkJSONValue(tableName, colName, fieldName, value string) error {
res, err := s.sfHelper.ExecuteAndProcessQuery(fmt.Sprintf(
"SELECT %s:%s FROM %s;",
colName, fieldName, tableName))
res, err := s.sfHelper.ExecuteAndProcessQuery(fmt.Sprintf("SELECT %s:%s FROM %s", colName, fieldName, tableName))
if err != nil {
return fmt.Errorf("json value check failed: %v", err)
}

if len(res.Records) == 0 {
return fmt.Errorf("bad json: empty result set from %s", tableName)
}

jsonVal := res.Records[0][0].Value
if jsonVal != value {
return fmt.Errorf("bad json value in field %s of column %s: %v. expected: %v", fieldName, colName, jsonVal, value)
Expand Down

0 comments on commit 6121541

Please sign in to comment.