-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreleasediff_test.go
71 lines (60 loc) · 1.46 KB
/
releasediff_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package releasediff
import (
"context"
"os"
"sync"
"testing"
"github.com/google/go-github/v68/github"
"golang.org/x/oauth2"
)
type TestCase struct {
Owner string
Repo string
Filter string
VerifyRelease bool
Release string
}
func TestMain(t *testing.T) {
tc := oauth2.NewClient(context.Background(), oauth2.StaticTokenSource(
&oauth2.Token{AccessToken: os.Getenv("GITHUB_TOKEN"), TokenType: "token"},
))
client := github.NewClient(tc)
testCases := []TestCase{
{
Owner: "kubernetes",
Repo: "ingress-nginx",
Filter: "^controller-.*$",
VerifyRelease: false,
Release: "controller-0.31.0",
},
{
Owner: "BESTSELLER",
Repo: "harpocrates",
VerifyRelease: false,
Release: "1.7.6",
},
{
Owner: "hashicorp",
Repo: "vault",
VerifyRelease: false,
Release: "v1.10.3",
},
}
var rate github.Rate
var wg sync.WaitGroup
for _, tc := range testCases {
wg.Add(1)
go func(testCase TestCase) {
defer wg.Done()
ghr, resp, err := New(client, testCase.Owner, testCase.Repo, testCase.Release, &Options{Filter: testCase.Filter, VerifyRelease: testCase.VerifyRelease})
if err != nil {
panic(err)
}
diff := ghr.Diff()
t.Logf("%s/%s:\tThere are %d releases between %s and %s\n", testCase.Owner, testCase.Repo, diff, ghr.Release, ghr.Options.Release)
rate = resp.Rate
}(tc)
}
wg.Wait()
t.Logf("%v\n", rate)
}