Skip to content

Commit

Permalink
test: restrict custom normalizations to BigQueryDataTransferConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
jingyih committed Sep 18, 2024
1 parent 0f14fe0 commit b8bf4dc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
10 changes: 6 additions & 4 deletions tests/e2e/normalize.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,12 @@ func normalizeKRMObject(t *testing.T, u *unstructured.Unstructured, project test
visitor.replacePaths[".status.observedState.cloudResource.serviceAccountID"] = "bqcx-${projectNumber}[email protected]"

// Specific to BigQueryDataTransferConfig
visitor.replacePaths[".status.observedState.nextRunTime"] = "1970-01-01T00:00:00Z"
visitor.replacePaths[".status.observedState.ownerInfo.email"] = "[email protected]"
visitor.replacePaths[".status.observedState.userID"] = "0000000000000000000"
visitor.removePaths.Insert(".status.observedState.state") // data transfer run state, which depends on timing
if u.GetKind() == "BigQueryDataTransferConfig" {
visitor.replacePaths[".status.observedState.nextRunTime"] = "1970-01-01T00:00:00Z"
visitor.replacePaths[".status.observedState.ownerInfo.email"] = "[email protected]"
visitor.replacePaths[".status.observedState.userID"] = "0000000000000000000"
visitor.removePaths.Insert(".status.observedState.state") // data transfer run state, which depends on timing
}

// TODO: This should not be needed, we want to avoid churning the kube objects
visitor.sortSlices.Insert(".spec.access")
Expand Down
7 changes: 6 additions & 1 deletion tests/e2e/unified_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,12 @@ func runScenario(ctx context.Context, t *testing.T, testPause bool, fixture reso
addReplacement("nextRunTime", "2024-04-01T12:34:56.123456Z")
addReplacement("ownerInfo.email", "[email protected]")
addReplacement("userId", "0000000000000000000")
jsonMutators = append(jsonMutators, func(obj map[string]any) { // special handling because the field includes dot
jsonMutators = append(jsonMutators, func(obj map[string]any) {
if _, found, err := unstructured.NestedString(obj, "destinationDatasetId"); err != nil || !found {
// This is a hack to only run this mutator for BigQueryDataTransferConfig objects.
return
}
// special handling because the field includes dot
if _, found, _ := unstructured.NestedString(obj, "params", "connector.authentication.oauth.clientId"); found {
if err := unstructured.SetNestedField(obj, "client-id", "params", "connector.authentication.oauth.clientId"); err != nil {
t.Fatal(err)
Expand Down

0 comments on commit b8bf4dc

Please sign in to comment.