forked from GoogleCloudPlatform/magic-modules
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Fix permadiff that reorders
stateful_external_ip
blocks on …
…`google_compute_instance_group_manager` and `google_compute_region_instance_group_manager` resources" (GoogleCloudPlatform#9754) This reverts commit de43d70.
- Loading branch information
1 parent
89f2396
commit 24ff156
Showing
6 changed files
with
102 additions
and
460 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
...party/terraform/services/compute/resource_compute_instance_group_manager_internal_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package compute | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestInstanceGroupManager_parseUniqueId(t *testing.T) { | ||
expectations := map[string][]string{ | ||
"projects/imre-test/global/instanceTemplates/example-template-custom?uniqueId=123": {"projects/imre-test/global/instanceTemplates/example-template-custom", "123"}, | ||
"https://www.googleapis.com/compute/v1/projects/imre-test/global/instanceTemplates/example-template-custom?uniqueId=123": {"https://www.googleapis.com/compute/v1/projects/imre-test/global/instanceTemplates/example-template-custom", "123"}, | ||
"projects/imre-test/global/instanceTemplates/example-template-custom": {"projects/imre-test/global/instanceTemplates/example-template-custom", ""}, | ||
"https://www.googleapis.com/compute/v1/projects/imre-test/global/instanceTemplates/example-template-custom": {"https://www.googleapis.com/compute/v1/projects/imre-test/global/instanceTemplates/example-template-custom", ""}, | ||
"example-template-custom?uniqueId=123": {"example-template-custom", "123"}, | ||
|
||
// this test demonstrates that uniqueIds can't override eachother | ||
"projects/imre-test/global/instanceTemplates/example?uniqueId=123?uniqueId=456": {"projects/imre-test/global/instanceTemplates/example", "123?uniqueId=456"}, | ||
} | ||
|
||
for k, v := range expectations { | ||
aName, aUniqueId := parseUniqueId(k) | ||
if v[0] != aName { | ||
t.Errorf("parseUniqueId failed; name of %v should be %v, not %v", k, v[0], aName) | ||
} | ||
if v[1] != aUniqueId { | ||
t.Errorf("parseUniqueId failed; uniqueId of %v should be %v, not %v", k, v[1], aUniqueId) | ||
} | ||
} | ||
} | ||
|
||
func TestInstanceGroupManager_compareInstanceTemplate(t *testing.T) { | ||
shouldAllMatch := []string{ | ||
// uniqueId not present | ||
"https://www.googleapis.com/compute/v1/projects/imre-test/global/instanceTemplates/example-template-custom", | ||
"projects/imre-test/global/instanceTemplates/example-template-custom", | ||
// uniqueId present | ||
"https://www.googleapis.com/compute/v1/projects/imre-test/global/instanceTemplates/example-template-custom?uniqueId=123", | ||
"projects/imre-test/global/instanceTemplates/example-template-custom?uniqueId=123", | ||
} | ||
shouldNotMatch := map[string]string{ | ||
// mismatching name | ||
"https://www.googleapis.com/compute/v1/projects/imre-test/global/instanceTemplates/example-template-custom": "projects/imre-test/global/instanceTemplates/example-template-custom2", | ||
"projects/imre-test/global/instanceTemplates/example-template-custom": "https://www.googleapis.com/compute/v1/projects/imre-test/global/instanceTemplates/example-template-custom2", | ||
// matching name, but mismatching uniqueId | ||
"https://www.googleapis.com/compute/v1/projects/imre-test/global/instanceTemplates/example-template-custom?uniqueId=123": "projects/imre-test/global/instanceTemplates/example-template-custom?uniqueId=1234", | ||
"projects/imre-test/global/instanceTemplates/example-template-custom?uniqueId=123": "https://www.googleapis.com/compute/v1/projects/imre-test/global/instanceTemplates/example-template-custom?uniqueId=1234", | ||
} | ||
for _, v1 := range shouldAllMatch { | ||
for _, v2 := range shouldAllMatch { | ||
if !compareSelfLinkRelativePathsIgnoreParams("", v1, v2, nil) { | ||
t.Fatalf("compareSelfLinkRelativePathsIgnoreParams did not match (and should have) %v and %v", v1, v2) | ||
} | ||
} | ||
} | ||
|
||
for v1, v2 := range shouldNotMatch { | ||
if compareSelfLinkRelativePathsIgnoreParams("", v1, v2, nil) { | ||
t.Fatalf("compareSelfLinkRelativePathsIgnoreParams did match (and shouldn't) %v and %v", v1, v2) | ||
} | ||
} | ||
} | ||
|
||
func TestInstanceGroupManager_convertUniqueId(t *testing.T) { | ||
matches := map[string]string{ | ||
// uniqueId not present (should return the same) | ||
"https://www.googleapis.com/compute/v1/projects/imre-test/global/instanceTemplates/example-template-custom": "https://www.googleapis.com/compute/v1/projects/imre-test/global/instanceTemplates/example-template-custom", | ||
"projects/imre-test/global/instanceTemplates/example-template-custom": "projects/imre-test/global/instanceTemplates/example-template-custom", | ||
// uniqueId present (should return the last component replaced) | ||
"https://www.googleapis.com/compute/v1/projects/imre-test/global/instanceTemplates/example-template-custom?uniqueId=123": "https://www.googleapis.com/compute/v1/projects/imre-test/global/instanceTemplates/123", | ||
"projects/imre-test/global/instanceTemplates/example-template-custom?uniqueId=123": "projects/imre-test/global/instanceTemplates/123", | ||
"tf-test-igm-8amncgtq22?uniqueId=8361222501423044003": "8361222501423044003", | ||
} | ||
for input, expected := range matches { | ||
actual := ConvertToUniqueIdWhenPresent(input) | ||
if actual != expected { | ||
t.Fatalf("invalid return value by ConvertToUniqueIdWhenPresent for input %v; expected: %v, actual: %v", input, expected, actual) | ||
} | ||
} | ||
} |
Oops, something went wrong.