Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix instance migrate test self link comparisons #4749

Merged
merged 1 commit into from
Oct 24, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 29 additions & 8 deletions google/resource_compute_instance_migrate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"log"
"os"
"strings"
"testing"

"google.golang.org/api/compute/v1"
Expand Down Expand Up @@ -863,18 +864,38 @@ func runInstanceMigrateTest(t *testing.T, id, testName string, version int, attr
}

for k, v := range expected {
if attributes[k] != v {
t.Fatalf(
"bad: %s\n\n expected: %#v -> %#v\n got: %#v -> %#v\n in: %#v",
testName, k, expected[k], k, attributes[k], attributes)
// source is the only self link, so compare by relpaths if source is being
// compared
if strings.HasSuffix(k, "source") {
if !compareSelfLinkOrResourceName("", attributes[k], v, nil) && attributes[k] != v {
t.Fatalf(
"bad uri: %s\n\n expected: %#v -> %#v\n got: %#v -> %#v\n in: %#v",
testName, k, expected[k], k, attributes[k], attributes)
}
} else {
if attributes[k] != v {
t.Fatalf(
"bad: %s\n\n expected: %#v -> %#v\n got: %#v -> %#v\n in: %#v",
testName, k, expected[k], k, attributes[k], attributes)
}
}
}

for k, v := range attributes {
if expected[k] != v {
t.Fatalf(
"bad: %s\n\n expected: %#v -> %#v\n got: %#v -> %#v\n in: %#v",
testName, k, expected[k], k, attributes[k], attributes)
// source is the only self link, so compare by relpaths if source is being
// compared
if strings.HasSuffix(k, "source") {
if !compareSelfLinkOrResourceName("", expected[k], v, nil) && expected[k] != v {
t.Fatalf(
"bad: %s\n\n expected: %#v -> %#v\n got: %#v -> %#v\n in: %#v",
testName, k, expected[k], k, attributes[k], expected)
}
} else {
if expected[k] != v {
t.Fatalf(
"bad: %s\n\n expected: %#v -> %#v\n got: %#v -> %#v\n in: %#v",
testName, k, expected[k], k, attributes[k], expected)
}
}
}
}
Expand Down