internal/fetchdatasource: fix test to work on macs Accept a wider range of URLs to accommodate Mac temp dirs. Change-Id: I2933b71ab1956a4fbf504e842d3ec2fe5c56e127 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/348795 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Jamal Carvalho <jamal@golang.org> Reviewed-by: Julie Qiu <julie@golang.org>
diff --git a/internal/fetchdatasource/fetchdatasource_test.go b/internal/fetchdatasource/fetchdatasource_test.go index 7d5ed75..efa1894 100644 --- a/internal/fetchdatasource/fetchdatasource_test.go +++ b/internal/fetchdatasource/fetchdatasource_test.go
@@ -10,7 +10,7 @@ "fmt" "log" "os" - "path" + "regexp" "testing" "time" @@ -445,13 +445,13 @@ if got.SourceInfo != nil { gotURL = got.SourceInfo.RepoURL() } - wantURL := "/files/*/*/github.com/my/module/" - m, err := path.Match(wantURL, gotURL) + const wantRegexp = "^/files/.*/github.com/my/module/$" + matched, err := regexp.MatchString(wantRegexp, gotURL) if err != nil { t.Fatal(err) } - if !m { - t.Errorf("RepoURL: got %q, want match of %q", gotURL, wantURL) + if !matched { + t.Errorf("RepoURL: got %q, want match of %q", gotURL, wantRegexp) } diff := cmp.Diff(test.want, got, cmp.AllowUnexported(source.Info{}), cmpopts.IgnoreFields(source.Info{}, "repoURL")) if diff != "" {