-
Notifications
You must be signed in to change notification settings - Fork 2
/
github_test.go
74 lines (66 loc) · 1.29 KB
/
github_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
72
73
74
//go:build e2e
// +build e2e
package resource_test
import (
"os"
"testing"
"github.com/stretchr/testify/require"
resource "github.com/telia-oss/github-pr-resource"
)
func TestListTeamMembers(t *testing.T) {
source := resource.Source{
Repository: "cloudfoundry/community",
AccessToken: os.Getenv("GITHUB_ACCESS_TOKEN"),
}
client, err := resource.NewGithubClient(&source)
require.NoError(t, err)
val, err := client.ListTeamMembers("wg-admin")
require.NoError(t, err)
require.Contains(t, val, "thelinuxfoundation")
}
func Test_cleanBotUserName(t *testing.T) {
type args struct {
username string
}
tests := []struct {
name string
args args
want string
}{
{
name: "Main Test Case",
args: args{
username: "infratest[bot]",
},
want: "infratest",
},
{
name: "Without suffix bot",
args: args{
username: "infratest",
},
want: "infratest",
},
{
name: "Bot only",
args: args{
username: "[bot]",
},
want: "",
},
{
name: "Bot at start",
args: args{
username: "[bot]infratest",
},
want: "[bot]infratest",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := cleanBotUserName(tt.args.username); got != tt.want {
t.Errorf("cleanBotUserName() = %v, want %v", got, tt.want)
}
})
}
}