-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgithub_test.go
More file actions
61 lines (58 loc) · 1.58 KB
/
github_test.go
File metadata and controls
61 lines (58 loc) · 1.58 KB
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
package main
import (
"os"
"testing"
"time"
"github.com/joho/godotenv"
)
func TestGitHubClient_IsImageAlreadyMirrored(t *testing.T) {
godotenv.Load()
cfg := GithubClientConfig{
Token: os.Getenv("GITHUB_TOKEN"),
Org: "1mgr",
Timeout: 30 * time.Second,
CheckInterval: 1 * time.Second,
}
type args struct {
image string
}
tests := []struct {
name string
args args
mirrored bool
sinceLastMirrorChecker func(time.Duration) bool
}{
{
name: "postgres 16",
args: args{image: "postgres:16"},
mirrored: true,
sinceLastMirrorChecker: func(d time.Duration) bool { return true },
},
{
name: "postgres 11",
args: args{image: "postgres:11"},
mirrored: true,
sinceLastMirrorChecker: func(d time.Duration) bool { return d > time.Hour*24 },
},
{
name: "grafana/grafana-oss",
args: args{image: "grafana/grafana-oss:latest"},
mirrored: true,
sinceLastMirrorChecker: func(d time.Duration) bool { return true },
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
g := &GitHubClient{
Config: cfg,
}
got, got1 := g.IsImageAlreadyMirrored(tt.args.image)
if got != tt.mirrored {
t.Errorf("GitHubClient.IsImageAlreadyMirrored() got = %v, want %v", got, tt.mirrored)
}
if !tt.sinceLastMirrorChecker(got1) {
t.Errorf("GitHubClient.IsImageAlreadyMirrored() got1 = %v", got1)
}
})
}
}