@@ -42,45 +42,61 @@ class AzureRepositoryProviderTest extends Specification {
42
42
}
43
43
'''
44
44
45
- def ' should return repo url' () {
45
+ def ' should parse repo fields from path' () {
46
+ expect :
47
+ AzureRepositoryProvider . getUniformPath(PATH ) == EXPECTED
46
48
47
- given :
48
- def config = new ConfigSlurper (). parse(CONFIG )
49
- def obj = new ProviderConfig (' azurerepos' , config. providers. azurerepos as ConfigObject )
49
+ where :
50
+ PATH | EXPECTED
51
+ ' t-neumann/hello' | [' t-neumann' , ' hello' , ' hello' ]
52
+ ' ORGANIZATION/PROJECT/hello' | [' ORGANIZATION' ,' PROJECT' ,' hello' ]
53
+ ' ORGANIZATION/PROJECT/_git/hello' | [' ORGANIZATION' ,' PROJECT' ,' hello' ]
50
54
51
- expect :
52
- new AzureRepositoryProvider (' t-neumann/hello' , obj). getEndpointUrl() == ' https://dev.azure.com/t-neumann/hello/_apis/git/repositories/hello'
53
55
}
54
56
55
- def ' should return repo with organization url' () {
57
+ def ' should throw exception if wrong path' () {
58
+ when :
59
+ def path = AzureRepositoryProvider . getUniformPath(PATH )
56
60
57
- given :
58
- def config = new ConfigSlurper () . parse( CONFIG )
59
- def obj = new ProviderConfig ( ' azurerepos ' , config . providers . azurerepos as ConfigObject )
61
+ then :
62
+ def exception = thrown( IllegalArgumentException )
63
+ exception ?. message == EXCEPTION
60
64
61
- expect :
62
- new AzureRepositoryProvider (' ORGANIZATION/PROJECT/hello' , obj). getEndpointUrl() == ' https://dev.azure.com/ORGANIZATION/PROJECT/_apis/git/repositories/hello'
65
+ where :
66
+ PATH | EXCEPTION
67
+ ' incorrect_path_1' | " Unexpected Azure repository path format - offending value: 'incorrect_path_1'"
68
+ ' ORG/PROJ/hello/incorrect' | " Unexpected Azure repository path format - offending value: 'ORG/PROJ/hello/incorrect'"
63
69
}
64
70
65
- def ' should return project URL ' () {
71
+ def ' should return repo url ' () {
66
72
67
73
given :
68
74
def config = new ConfigSlurper (). parse(CONFIG )
69
75
def obj = new ProviderConfig (' azurerepos' , config. providers. azurerepos as ConfigObject )
70
76
71
77
expect :
72
- new AzureRepositoryProvider (' t-neumann/hello ' , obj). getRepositoryUrl () == ' https://dev.azure.com/t-neumann/hello '
78
+ new AzureRepositoryProvider (PATH , obj). getEndpointUrl () == EXPECTED
73
79
80
+ where :
81
+ PATH | EXPECTED
82
+ ' t-neumann/hello' | ' https://dev.azure.com/t-neumann/hello/_apis/git/repositories/hello'
83
+ ' ORGANIZATION/PROJECT/hello' | ' https://dev.azure.com/ORGANIZATION/PROJECT/_apis/git/repositories/hello'
84
+ ' ORGANIZATION/PROJECT/_git/hello' | ' https://dev.azure.com/ORGANIZATION/PROJECT/_apis/git/repositories/hello'
74
85
}
75
86
76
- def ' should return project with organization URL' () {
87
+ def ' should return project URL' () {
77
88
78
89
given :
79
90
def config = new ConfigSlurper (). parse(CONFIG )
80
91
def obj = new ProviderConfig (' azurerepos' , config. providers. azurerepos as ConfigObject )
81
92
82
93
expect :
83
- new AzureRepositoryProvider (' ORGANIZATION/PROJECT/hello' , obj). getRepositoryUrl() == ' https://dev.azure.com/ORGANIZATION/PROJECT/hello'
94
+ new AzureRepositoryProvider (PATH , obj). getRepositoryUrl() == EXPECTED
95
+ where :
96
+ PATH | EXPECTED
97
+ ' t-neumann/hello' | ' https://dev.azure.com/t-neumann/hello'
98
+ ' ORGANIZATION/PROJECT/hello' | ' https://dev.azure.com/ORGANIZATION/PROJECT/hello'
99
+ ' ORGANIZATION/PROJECT/_git/hello' | ' https://dev.azure.com/ORGANIZATION/PROJECT/_git/hello'
84
100
85
101
}
86
102
0 commit comments