Skip to content

Commit b50b9e6

Browse files
Merge pull request GoogleCloudPlatform#1719 from gemmahou/fix
tests: vcr: minor revisions
2 parents f42009d + 85e9ce9 commit b50b9e6

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

tests/e2e/unified_test.go

+12-6
Original file line numberDiff line numberDiff line change
@@ -1027,14 +1027,20 @@ func configureVCR(t *testing.T, h *create.Harness) {
10271027
result = strings.Replace(result, os.Getenv("TEST_ORG_ID"), "123450001", -1)
10281028
}
10291029

1030-
// Replace user info
1031-
obj := make(map[string]any)
1032-
if err := json.Unmarshal([]byte(s), &obj); err == nil {
1033-
toReplace, _, _ := unstructured.NestedString(obj, "user")
1034-
if len(toReplace) != 0 {
1035-
result = strings.Replace(result, toReplace, "[email protected]", -1)
1030+
addReplacement := func(path string, newValue string) {
1031+
tokens := strings.Split(path, ".")
1032+
obj := make(map[string]any)
1033+
if err := json.Unmarshal([]byte(s), &obj); err == nil {
1034+
toReplace, found, _ := unstructured.NestedString(obj, tokens...)
1035+
if found {
1036+
result = strings.Replace(result, toReplace, newValue, -1)
1037+
}
10361038
}
10371039
}
1040+
// Replace user info
1041+
addReplacement("user", "[email protected]")
1042+
// Replace billing account name
1043+
addReplacement("billingAccountName", "billingAccounts/123456-777777-000001")
10381044
return result
10391045
}
10401046

0 commit comments

Comments
 (0)