Files
kandev/apps/backend/internal/gitlab/glab_client_test.go
T
2026-07-21 23:24:22 +01:00

53 lines
1.3 KiB
Go

package gitlab
import "testing"
func TestGLabClientSatisfiesProviderActionContract(t *testing.T) {
var _ Client = (*GLabClient)(nil)
}
func TestParseGlabToken_ExtractsValue(t *testing.T) {
output := `Logged in to gitlab.com as alice (oauth_token)
✓ Token: glpat-AAAAA-BBBBB
✓ Token scopes: api`
got := parseGlabToken(output)
if got != "glpat-AAAAA-BBBBB" {
t.Errorf("got %q, want glpat-AAAAA-BBBBB", got)
}
}
func TestParseGlabToken_LowercaseLabel(t *testing.T) {
got := parseGlabToken("token: glpat-xyz")
if got != "glpat-xyz" {
t.Errorf("got %q, want glpat-xyz", got)
}
}
func TestParseGlabToken_NoToken(t *testing.T) {
got := parseGlabToken("Token: <no token>")
if got != "" {
t.Errorf("got %q, want empty", got)
}
}
func TestParseGlabToken_Empty(t *testing.T) {
if got := parseGlabToken(""); got != "" {
t.Errorf("got %q, want empty", got)
}
}
func TestStripScheme(t *testing.T) {
cases := map[string]string{
"https://gitlab.com": "gitlab.com",
"http://gitlab.acme.corp": "gitlab.acme.corp",
"https://gitlab.com/": "gitlab.com",
"gitlab.example.com": "gitlab.example.com",
"https://gitlab.example.com/": "gitlab.example.com",
}
for in, want := range cases {
if got := stripScheme(in); got != want {
t.Errorf("stripScheme(%q) = %q, want %q", in, got, want)
}
}
}