Skip to content

Commit

Permalink
better tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Amogh-Bharadwaj committed Jan 1, 2024
1 parent 83ffae0 commit adb493d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
3 changes: 1 addition & 2 deletions flow/connectors/sql/query_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -412,8 +412,7 @@ func toQValue(kind qvalue.QValueKind, val interface{}) (qvalue.QValue, error) {
vraw := val.(*interface{})
vstring, ok := (*vraw).(string)
if !ok {
return qvalue.QValue{},
fmt.Errorf("failed to obtain string from json, possibly due to null field value")
slog.Warn("A parsed JSON value was not a string. Likely a null field value")
}

if strings.HasPrefix(vstring, "[") {
Expand Down
2 changes: 1 addition & 1 deletion flow/e2e/snowflake/peer_flow_sf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,7 @@ func (s PeerFlowE2ETestSuiteSF) Test_Types_SF() {
}

// check if JSON on snowflake side is a good JSON
err = s.checkJSONValue(dstTableName, "c17", "sai")
err = s.checkJSONValue(dstTableName, "c17", "sai", "1")
require.NoError(s.t, err)

// Make sure that there are no nulls
Expand Down
10 changes: 6 additions & 4 deletions flow/e2e/snowflake/qrep_flow_sf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func (s PeerFlowE2ETestSuiteSF) compareTableContentsSF(tableName, selector strin
s.compareTableContentsWithDiffSelectorsSF(tableName, selector, selector, false)
}

func (s PeerFlowE2ETestSuiteSF) checkJSONValue(tableName, colName, fieldName string) error {
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))
Expand All @@ -32,8 +32,8 @@ func (s PeerFlowE2ETestSuiteSF) checkJSONValue(tableName, colName, fieldName str
}

jsonVal := res.Records[0].Entries[0].Value
if jsonVal == "" {
return fmt.Errorf("bad json value in field %s of column %s: %v", fieldName, colName, jsonVal)
if jsonVal != value {
return fmt.Errorf("bad json value in field %s of column %s: %v. expected: %v", fieldName, colName, jsonVal, value)
}
return nil
}
Expand Down Expand Up @@ -104,6 +104,9 @@ func (s PeerFlowE2ETestSuiteSF) Test_Complete_QRep_Flow_Avro_SF() {
sel := e2e.GetOwnersSelectorStringsSF()
s.compareTableContentsWithDiffSelectorsSF(tblName, sel[0], sel[1], false)

err = s.checkJSONValue(dstSchemaQualified, "f7", "key", "\"value\"")
require.NoError(s.t, err)

env.AssertExpectations(s.t)
}

Expand Down Expand Up @@ -262,7 +265,6 @@ func (s PeerFlowE2ETestSuiteSF) Test_Complete_QRep_Flow_Avro_SF_S3_Integration()
s.attachSchemaSuffix(tblName),
dstSchemaQualified,
query,

sfPeer,
"",
false,
Expand Down

0 comments on commit adb493d

Please sign in to comment.