🐛 Fix flaky tests in cron/data/add (#1185)

* fix

* naming
This commit is contained in:
laurentsimon 2021-10-28 11:18:35 -07:00 committed by GitHub
parent 0ba864e9c2
commit d9e35cda2a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -27,10 +27,6 @@ import (
"github.com/ossf/scorecard/v3/repos"
)
func isLessThanRepoURL(x, y *repos.RepoURI) bool {
return x.URL() < y.URL()
}
type fields struct {
host string
owner string
@ -38,6 +34,11 @@ type fields struct {
metadata []string
}
//nolint: gocritic
func lessThanURI(x, y repos.RepoURI) bool {
return fmt.Sprintf("%+v", x) < fmt.Sprintf("%+v", y)
}
func TestGetRepoURLs(t *testing.T) {
t.Parallel()
testcases := []struct {
@ -135,6 +136,7 @@ func TestGetRepoURLs(t *testing.T) {
}
for _, testcase := range testcases {
testcase := testcase
t.Run(testcase.name, func(t *testing.T) {
t.Parallel()
testFile, err := os.OpenFile(testcase.filename, os.O_RDONLY, 0o644)
@ -172,8 +174,8 @@ func TestGetRepoURLs(t *testing.T) {
return true
})
if !cmp.Equal(rs, repoURLs, exp, cmpopts.EquateEmpty(), cmpopts.SortSlices(isLessThanRepoURL)) {
t.Errorf("testcase failed. expected %+v, got %+v", testcase.outcome, repoURLs)
if !cmp.Equal(rs, repoURLs, exp, cmpopts.EquateEmpty(), cmpopts.SortSlices(lessThanURI)) {
t.Errorf("testcase failed. expected %+v, got %+v", rs, repoURLs)
}
})
}