diff options
| author | Paul Buetow <paul@buetow.org> | 2026-05-28 10:02:03 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-05-28 10:02:03 +0300 |
| commit | dcf90064e3671d4eccc5f0f59182a4afe23c95f9 (patch) | |
| tree | b2d866e647e036962a0f000d6aea8517097a234e /internal/cli/forge_client_test.go | |
| parent | 1325155d123d9403ea964152b125efd960522603 (diff) | |
refactor(forge): unify repo lifecycle across GitHub and Codeberg (dq)
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") + } + }) +} |
