-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathscm_test.go
90 lines (83 loc) · 2.4 KB
/
scm_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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
// SPDX-License-Identifier: Apache-2.0
package scm
import (
"context"
"testing"
)
func TestSCM_New(t *testing.T) {
// setup tests
tests := []struct {
failure bool
setup *Setup
}{
{
failure: false,
setup: &Setup{
Driver: "github",
Address: "https://github.com",
ClientID: "foo",
ClientSecret: "bar",
ServerAddress: "https://vela-server.example.com",
ServerWebhookAddress: "",
StatusContext: "continuous-integration/vela",
WebUIAddress: "https://vela.example.com",
OAuthScopes: []string{"repo", "repo:status", "user:email", "read:user", "read:org"},
},
},
{
failure: true,
setup: &Setup{
Driver: "gitlab",
Address: "https://gitlab.com",
ClientID: "foo",
ClientSecret: "bar",
ServerAddress: "https://vela-server.example.com",
ServerWebhookAddress: "",
StatusContext: "continuous-integration/vela",
WebUIAddress: "https://vela.example.com",
OAuthScopes: []string{"repo", "repo:status", "user:email", "read:user", "read:org"},
},
},
{
failure: true,
setup: &Setup{
Driver: "bitbucket",
Address: "https://bitbucket.org",
ClientID: "foo",
ClientSecret: "bar",
ServerAddress: "https://vela-server.example.com",
ServerWebhookAddress: "",
StatusContext: "continuous-integration/vela",
WebUIAddress: "https://vela.example.com",
OAuthScopes: []string{"repo", "repo:status", "user:email", "read:user", "read:org"},
},
},
{
failure: true,
setup: &Setup{
Driver: "github",
Address: "",
ClientID: "foo",
ClientSecret: "bar",
ServerAddress: "https://vela-server.example.com",
ServerWebhookAddress: "",
StatusContext: "continuous-integration/vela",
WebUIAddress: "https://vela.example.com",
OAuthScopes: []string{"repo", "repo:status", "user:email", "read:user", "read:org"},
},
},
}
// run tests
for _, test := range tests {
_, err := New(context.Background(), test.setup)
if test.failure {
if err == nil {
t.Errorf("New should have returned err")
}
continue
}
if err != nil {
t.Errorf("New returned err: %v", err)
}
}
}