@@ -20,7 +20,6 @@ import (
2020 "testing"
2121
2222 "github.com/fluxcd/go-git-providers/gitprovider"
23- gogitlab "github.com/xanzy/go-gitlab"
2423)
2524
2625func TestSupportedDomain (t * testing.T ) {
@@ -40,31 +39,16 @@ func TestSupportedDomain(t *testing.T) {
4039 opts : gitprovider .WithDomain ("my-gitlab.dev.com" ),
4140 want : "https://my-gitlab.dev.com" ,
4241 },
43- {
44- name : "custom domain without protocol with port" ,
45- opts : gitprovider .WithDomain ("my-gitlab.dev.com:1234" ),
46- want : "https://my-gitlab.dev.com:1234" ,
47- },
4842 {
4943 name : "custom domain with https protocol" ,
5044 opts : gitprovider .WithDomain ("https://my-gitlab.dev.com" ),
5145 want : "https://my-gitlab.dev.com" ,
5246 },
53- {
54- name : "custom domain with https protocol with port" ,
55- opts : gitprovider .WithDomain ("https://my-gitlab.dev.com:1234" ),
56- want : "https://my-gitlab.dev.com:1234" ,
57- },
5847 {
5948 name : "custom domain with http protocol" ,
6049 opts : gitprovider .WithDomain ("http://my-gitlab.dev.com" ),
6150 want : "http://my-gitlab.dev.com" ,
6251 },
63- {
64- name : "custom domain with http protocol with port" ,
65- opts : gitprovider .WithDomain ("http://my-gitlab.dev.com:1234" ),
66- want : "http://my-gitlab.dev.com:1234" ,
67- },
6852 }
6953 for _ , tt := range tests {
7054 t .Run (tt .name , func (t * testing.T ) {
@@ -77,61 +61,6 @@ func TestSupportedDomain(t *testing.T) {
7761 }
7862}
7963
80- func TestBaseURL (t * testing.T ) {
81- tests := []struct {
82- name string
83- opts gitprovider.ClientOption
84- expected string
85- }{
86- {
87- name : "gitlab.com domain" ,
88- opts : gitprovider .WithDomain ("gitlab.com" ),
89- expected : "https://gitlab.com/api/v4/" ,
90- },
91- {
92- name : "custom domain without protocol" ,
93- opts : gitprovider .WithDomain ("my-gitlab.dev.com" ),
94- expected : "https://my-gitlab.dev.com/api/v4/" ,
95- },
96- {
97- name : "custom domain without protocol with port" ,
98- opts : gitprovider .WithDomain ("my-gitlab.dev.com:1234" ),
99- expected : "https://my-gitlab.dev.com:1234/api/v4/" ,
100- },
101- {
102- name : "custom domain with https protocol" ,
103- opts : gitprovider .WithDomain ("https://my-gitlab.dev.com" ),
104- expected : "https://my-gitlab.dev.com/api/v4/" ,
105- },
106- {
107- name : "custom domain with https protocol with port" ,
108- opts : gitprovider .WithDomain ("https://my-gitlab.dev.com:1234" ),
109- expected : "https://my-gitlab.dev.com:1234/api/v4/" ,
110- },
111- {
112- name : "custom domain with http protocol" ,
113- opts : gitprovider .WithDomain ("http://my-gitlab.dev.com" ),
114- expected : "http://my-gitlab.dev.com/api/v4/" ,
115- },
116- {
117- name : "custom domain with http protocol with port" ,
118- opts : gitprovider .WithDomain ("http://my-gitlab.dev.com:1234" ),
119- expected : "http://my-gitlab.dev.com:1234/api/v4/" ,
120- },
121- }
122- for _ , tt := range tests {
123- t .Run (tt .name , func (t * testing.T ) {
124- c1 , _ := NewClient ("token" , "oauth2" , tt .opts )
125- gc1 := c1 .Raw ().(* gogitlab.Client )
126- assertEqual (t , tt .expected , gc1 .BaseURL ().String ())
127-
128- c2 , _ := NewClient ("token" , "pat" , tt .opts )
129- gc2 := c2 .Raw ().(* gogitlab.Client )
130- assertEqual (t , tt .expected , gc2 .BaseURL ().String ())
131- })
132- }
133- }
134-
13564func assertEqual (t * testing.T , a interface {}, b interface {}) {
13665 if a != b {
13766 t .Fatalf ("%s != %s" , a , b )
0 commit comments