Skip to content

Commit 8d09e5e

Browse files
committed
badgestorer: remove rand string in github test
1 parent f4dd5a3 commit 8d09e5e

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

pkg/testcoverage/badgestorer/github_test.go

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@ package badgestorer_test
22

33
import (
44
"context"
5+
"fmt"
56
"os"
7+
"runtime"
68
"testing"
9+
"time"
710

811
"github.com/google/go-github/v56/github"
912
"github.com/stretchr/testify/assert"
10-
"golang.org/x/exp/rand"
1113

1214
. "github.com/vladopajic/go-test-coverage/v2/pkg/testcoverage/badgestorer"
1315
)
@@ -52,9 +54,9 @@ func Test_Github(t *testing.T) {
5254
Owner: "vladopajic",
5355
Repository: "go-test-coverage",
5456
Branch: "badges-integration-test",
55-
// random badge name must be used because two tests running from different platforms
57+
// badge name must be unique because two tests running from different platforms
5658
// in CI can cause race condition if badge has the same name
57-
FileName: "badge_" + randString() + ".svg",
59+
FileName: fmt.Sprintf("badge_%s_%d.svg", runtime.GOOS, time.Now().UnixNano()),
5860
}
5961
s := NewGithub(cfg)
6062

@@ -108,14 +110,3 @@ func deleteFile(t *testing.T, cfg Git) {
108110
)
109111
assert.NoError(t, err)
110112
}
111-
112-
func randString() string {
113-
letterRunes := []rune("abcdefghijklmnopqrstuvwxyz")
114-
115-
b := make([]rune, 10)
116-
for i := range b {
117-
b[i] = letterRunes[rand.Intn(len(letterRunes))]
118-
}
119-
120-
return string(b)
121-
}

0 commit comments

Comments
 (0)