@@ -164,6 +164,9 @@ func TestNewProvider(t *testing.T) {
164164 args args
165165 wantErr bool
166166 errContains string
167+ wantBaseUrl string
168+ wantProject string
169+ wantRepo string
167170 }{
168171 {
169172 name : "nil options" ,
@@ -184,19 +187,36 @@ func TestNewProvider(t *testing.T) {
184187 errContains : "invalid Azure DevOps Server URL" ,
185188 },
186189 {
187- name : "valid modern url" ,
188- args : args {repoURL : "https://dev.azure.com/org/proj/_git/repo" , opts : & gitprovider.Options {Token : "token" }},
189- wantErr : false ,
190+ name : "valid modern url" ,
191+ args : args {repoURL : "https://dev.azure.com/org/proj/_git/repo" , opts : & gitprovider.Options {Token : "token" }},
192+ wantErr : false ,
193+ wantBaseUrl : "dev.azure.com" ,
194+ wantProject : "proj" ,
195+ wantRepo : "repo" ,
190196 },
191197 {
192- name : "valid legacy url" ,
193- args : args {repoURL : "https://org.visualstudio.com/proj/_git/repo" , opts : & gitprovider.Options {Token : "token" }},
194- wantErr : false ,
198+ name : "valid legacy url" ,
199+ args : args {repoURL : "https://org.visualstudio.com/proj/_git/repo" , opts : & gitprovider.Options {Token : "token" }},
200+ wantErr : false ,
201+ wantBaseUrl : "dev.azure.com" ,
202+ wantProject : "proj" ,
203+ wantRepo : "repo" ,
195204 },
196205 {
197- name : "valid self-hosted url" ,
198- args : args {repoURL : "https://azure.mycompany.org/mycollection/myproject/_git/myrepo" , opts : & gitprovider.Options {Token : "token" }},
199- wantErr : false ,
206+ name : "valid self-hosted url" ,
207+ args : args {repoURL : "https://azure.mycompany.org/mycollection/myproject/_git/myrepo" , opts : & gitprovider.Options {Token : "token" }},
208+ wantErr : false ,
209+ wantBaseUrl : "azure.mycompany.org" ,
210+ wantProject : "myproject" ,
211+ wantRepo : "myrepo" ,
212+ },
213+ {
214+ name : "valid self-hosted url" ,
215+ args : args {repoURL : "https://azure.mycompany.org/tfs/mycollection/myproject/_git/myrepo" , opts : & gitprovider.Options {Token : "token" }},
216+ wantErr : false ,
217+ wantBaseUrl : "azure.mycompany.org/tfs" ,
218+ wantProject : "myproject" ,
219+ wantRepo : "myrepo" ,
200220 },
201221 {
202222 name : "invalid self-hosted url" ,
@@ -205,6 +225,7 @@ func TestNewProvider(t *testing.T) {
205225 errContains : "invalid Azure DevOps Server URL" ,
206226 },
207227 }
228+
208229 for _ , tt := range testCases {
209230 t .Run (tt .name , func (t * testing.T ) {
210231 got , err := NewProvider (tt .args .repoURL , tt .args .opts )
@@ -217,6 +238,13 @@ func TestNewProvider(t *testing.T) {
217238 } else {
218239 require .NoError (t , err )
219240 require .NotNil (t , got )
241+ // Use type assertion to access internal fields for further validation
242+ p , ok := got .(* provider )
243+ require .True (t , ok )
244+ require .Equal (t , tt .wantProject , p .project )
245+ require .Equal (t , tt .wantRepo , p .repo )
246+ require .NotNil (t , p .connection )
247+ require .NotNil (t , tt .wantBaseUrl , p .connection .BaseUrl )
220248 }
221249 })
222250 }
0 commit comments