diff options
Diffstat (limited to 'internal/cli/forge_client_test.go')
| -rw-r--r-- | internal/cli/forge_client_test.go | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/internal/cli/forge_client_test.go b/internal/cli/forge_client_test.go new file mode 100644 index 0000000..84f819b --- /dev/null +++ b/internal/cli/forge_client_test.go @@ -0,0 +1,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") + } + }) +} |
