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
|
package cli
import (
"testing"
"codeberg.org/snonux/gitsyncer/internal/config"
)
func TestNewRepoClientForOrg(t *testing.T) {
t.Parallel()
t.Run("github", func(t *testing.T) {
client, ok := newRepoClientForOrg(config.Organization{
Host: "git@github.com",
Name: "acme",
GitHubToken: "token",
})
if !ok {
t.Fatal("expected supported github client")
}
if !client.HasToken() {
t.Fatal("expected github client token to be loaded")
}
})
t.Run("codeberg", func(t *testing.T) {
client, ok := newRepoClientForOrg(config.Organization{
Host: "git@codeberg.org",
Name: "acme",
CodebergToken: "token",
})
if !ok {
t.Fatal("expected supported codeberg client")
}
if !client.HasToken() {
t.Fatal("expected codeberg client token to be loaded")
}
})
t.Run("unsupported", func(t *testing.T) {
client, ok := newRepoClientForOrg(config.Organization{
Host: "ssh://example.org",
Name: "acme",
})
if ok {
t.Fatal("expected unsupported host")
}
if client != nil {
t.Fatal("expected nil client for unsupported host")
}
})
}
|