Skip to content

Commit

Permalink
Fix instance migrate test self link comparisons (#2530)
Browse files Browse the repository at this point in the history
Merged PR #2530.
  • Loading branch information
rileykarson authored and modular-magician committed Oct 24, 2019
1 parent c87ea1c commit d935f2e
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 10 deletions.
2 changes: 1 addition & 1 deletion build/terraform
2 changes: 1 addition & 1 deletion build/terraform-beta
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

0 comments on commit d935f2e

Please sign in to comment.