Skip to content

Commit

Permalink
Fix flaky TestFindOlderVersions due to gofakeit noun collision
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas11 committed Mar 28, 2024
1 parent e153154 commit ef9da91
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 4 additions & 0 deletions provider/pkg/versioning/findOlderVersions.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package versioning

import (
"log"
"sort"

"github.com/pulumi/pulumi-azure-native/v2/provider/pkg/openapi"
Expand All @@ -18,6 +19,9 @@ func findOlderVersions(specVersions ProvidersVersionResources, defaultVersion op
continue
}
olderVersions = append(olderVersions, version)
if len(olderVersions) > 1 {
log.Println("whaaa")
}
}
sort.Strings(olderVersions)
olderProviderVersions[providerName] = olderVersions
Expand Down
10 changes: 5 additions & 5 deletions provider/pkg/versioning/findOlderVersions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import (
)

func TestFindOlderVersions(t *testing.T) {
providerA := gofakeit.Noun()
resourceA := gofakeit.Noun()
resourceB := gofakeit.Noun()
providerA := "providerA"
resourceA := "resourceA"
resourceB := "resourceB"
olderVersion := fakeApiVersion(FakeApiVersion{})
versionA := fakeApiVersion(FakeApiVersion{GreaterThan: olderVersion})
versionB := fakeApiVersion(FakeApiVersion{GreaterThan: olderVersion})
Expand All @@ -36,7 +36,7 @@ func TestFindOlderVersions(t *testing.T) {
olderVersion,
},
}
assert.Equal(t, expected, olderVersions)
assert.Equal(t, expected, olderVersions, "olderVersion=%s, versionA=%s, versionB=%s", olderVersion, versionA, versionB)
}

type FakeApiVersion struct {
Expand All @@ -54,7 +54,7 @@ func fakeApiVersion(spec FakeApiVersion) openapi.ApiVersion {
min = min.AddDate(0, 0, 1)
}
if spec.LessThan != "" {
max, _ = time.Parse(ApiVersionLayout, spec.GreaterThan)
max, _ = time.Parse(ApiVersionLayout, spec.LessThan)
max = max.AddDate(0, 0, -1)
}
return gofakeit.DateRange(min, max).Format(ApiVersionLayout)
Expand Down

0 comments on commit ef9da91

Please sign in to comment.