23
23
alphaNumericTagProject = fmt .Sprintf ("https://%s/dataplatform/alpha-numeric-tag-project.git" , host )
24
24
tagsOutOfPatternProject = fmt .Sprintf ("https://%s/dataplatform/tags-out-of-pattern-project.git" , host )
25
25
greatNumbersTagProject = fmt .Sprintf ("https://%s/dataplatform/great-numbers-tag-project.git" , host )
26
+ disorderedTagsProject = fmt .Sprintf ("https://%s/dataplatform/disordered-tags-prject.git" , host )
26
27
)
27
28
28
29
func TestNewGitNoError (t * testing.T ) {
@@ -47,7 +48,7 @@ func TestNewGitRepositoryAlreadyClonedNoError(t *testing.T) {
47
48
func TestNewGitRepositoryNotFound (t * testing.T ) {
48
49
f := setup ()
49
50
f .gitLabVersioning .url = "any"
50
- f .gitLabVersioning .destinationDirectory = fmt . Sprintf ( "%s/%s" , os . Getenv ( "HOME" ), "no-set-project" )
51
+ f .gitLabVersioning .destinationDirectory = getDestinationDirectory ( "no-set-project" )
51
52
f .gitLabVersioning .username = "root"
52
53
f .gitLabVersioning .password = "password"
53
54
_ , err := f .newGitService ()
@@ -58,7 +59,7 @@ func TestNewGitRepositoryNotFound(t *testing.T) {
58
59
func TestNewGitEmptyRepositoryError (t * testing.T ) {
59
60
f := getValidSetup ()
60
61
f .gitLabVersioning .url = noBranchProject
61
- f .gitLabVersioning .destinationDirectory = fmt . Sprintf ( "%s/%s" , os . Getenv ( "HOME" ), "no-branch-project" )
62
+ f .gitLabVersioning .destinationDirectory = getDestinationDirectory ( "no-branch-project" )
62
63
_ , err := f .newGitService ()
63
64
tests .AssertError (t , err )
64
65
tests .AssertEqualValues (t , "error while initiating git package due to : remote repository is empty" , err .Error ())
@@ -117,7 +118,7 @@ func TestNewGitCommitGetCurrentVersionNoError(t *testing.T) {
117
118
func TestNewGitUpgradeRemoteRepositoryAddChangesError (t * testing.T ) {
118
119
f := getValidSetup ()
119
120
f .gitLabVersioning .url = noTagsProject
120
- f .gitLabVersioning .destinationDirectory = fmt . Sprintf ( "%s/%s" , os . Getenv ( "HOME" ), "no-tags-project" )
121
+ f .gitLabVersioning .destinationDirectory = getDestinationDirectory ( "no-tags-project" )
121
122
f .gitFunctions .errAddToStage = errors .New ("no changes to add" )
122
123
repo , err := f .newGitService ()
123
124
tests .AssertNoError (t , err )
@@ -137,7 +138,7 @@ func TestNewGitUpgradeRemoteRepositoryAddChangesError(t *testing.T) {
137
138
func TestNewGitUpgradeRemoteRepositoryCommitChangesError (t * testing.T ) {
138
139
f := getValidSetup ()
139
140
f .gitLabVersioning .url = noTagsProject
140
- f .gitLabVersioning .destinationDirectory = fmt . Sprintf ( "%s/%s" , os . Getenv ( "HOME" ), "no-tags-project" )
141
+ f .gitLabVersioning .destinationDirectory = getDestinationDirectory ( "no-tags-project" )
141
142
f .gitFunctions .errCommitChanges = errors .New ("commit is old dated" )
142
143
repo , err := f .newGitService ()
143
144
tests .AssertNoError (t , err )
@@ -157,7 +158,7 @@ func TestNewGitUpgradeRemoteRepositoryCommitChangesError(t *testing.T) {
157
158
func TestNewGitUpgradeRemoteRepositoryPushError (t * testing.T ) {
158
159
f := getValidSetup ()
159
160
f .gitLabVersioning .url = noTagsProject
160
- f .gitLabVersioning .destinationDirectory = fmt . Sprintf ( "%s/%s" , os . Getenv ( "HOME" ), "no-tags-project" )
161
+ f .gitLabVersioning .destinationDirectory = getDestinationDirectory ( "no-tags-project" )
161
162
f .gitFunctions .errPush = errors .New ("nothing to push" )
162
163
repo , err := f .newGitService ()
163
164
tests .AssertNoError (t , err )
@@ -177,7 +178,7 @@ func TestNewGitUpgradeRemoteRepositoryPushError(t *testing.T) {
177
178
func TestNewGitUpgradeRemoteRepositorySetTagError (t * testing.T ) {
178
179
f := getValidSetup ()
179
180
f .gitLabVersioning .url = noTagsProject
180
- f .gitLabVersioning .destinationDirectory = fmt . Sprintf ( "%s/%s" , os . Getenv ( "HOME" ), "no-tags-project" )
181
+ f .gitLabVersioning .destinationDirectory = getDestinationDirectory ( "no-tags-project" )
181
182
f .gitFunctions .errSetTag = errors .New ("unable to set new tag" )
182
183
repo , err := f .newGitService ()
183
184
tests .AssertNoError (t , err )
@@ -197,7 +198,7 @@ func TestNewGitUpgradeRemoteRepositorySetTagError(t *testing.T) {
197
198
func TestNewGitUpgradeRemoteRepositoryPushTagsError (t * testing.T ) {
198
199
f := getValidSetup ()
199
200
f .gitLabVersioning .url = noTagsProject
200
- f .gitLabVersioning .destinationDirectory = fmt . Sprintf ( "%s/%s" , os . Getenv ( "HOME" ), "no-tags-project" )
201
+ f .gitLabVersioning .destinationDirectory = getDestinationDirectory ( "no-tags-project" )
201
202
f .gitFunctions .errPushTag = errors .New ("unable to push tags to remote repository" )
202
203
repo , err := f .newGitService ()
203
204
tests .AssertNoError (t , err )
@@ -217,7 +218,7 @@ func TestNewGitUpgradeRemoteRepositoryPushTagsError(t *testing.T) {
217
218
func TestNewGitUpgradeRemoteRepositoryNoError (t * testing.T ) {
218
219
f := getValidSetup ()
219
220
f .gitLabVersioning .url = noTagsProject
220
- f .gitLabVersioning .destinationDirectory = fmt . Sprintf ( "%s/%s" , os . Getenv ( "HOME" ), "no-tags-project" )
221
+ f .gitLabVersioning .destinationDirectory = getDestinationDirectory ( "no-tags-project" )
221
222
repo , err := f .newGitService ()
222
223
tests .AssertNoError (t , err )
223
224
@@ -246,7 +247,7 @@ func TestNewGitUpgradeRemoteRepositoryNoError(t *testing.T) {
246
247
func TestNewGitUpgradeRemoteRepositoryProtectedTagError (t * testing.T ) {
247
248
f := getValidSetup ()
248
249
f .gitLabVersioning .url = protectedTagProject
249
- f .gitLabVersioning .destinationDirectory = fmt . Sprintf ( "%s/%s" , os . Getenv ( "HOME" ), "protected-tag-project" )
250
+ f .gitLabVersioning .destinationDirectory = getDestinationDirectory ( "protected-tag-project" )
250
251
repo , err := f .newGitService ()
251
252
tests .AssertNoError (t , err )
252
253
@@ -259,7 +260,7 @@ func TestNewGitUpgradeRemoteRepositoryProtectedTagError(t *testing.T) {
259
260
func TestNewGitUpgradeRemoteRepositoryAlreadyPushedTagError (t * testing.T ) {
260
261
f := getValidSetup ()
261
262
f .gitLabVersioning .url = noTagsProject
262
- f .gitLabVersioning .destinationDirectory = fmt . Sprintf ( "%s/%s" , os . Getenv ( "HOME" ), "no-tags-project" )
263
+ f .gitLabVersioning .destinationDirectory = getDestinationDirectory ( "no-tags-project" )
263
264
repo , err := f .newGitService ()
264
265
tests .AssertNoError (t , err )
265
266
@@ -282,7 +283,7 @@ func TestNewGitUpgradeRemoteRepositoryAlreadyPushedTagError(t *testing.T) {
282
283
func TestNewGitUpgradeRemoteRepositoryPushToProtectedBranchError (t * testing.T ) {
283
284
f := getValidSetup ()
284
285
f .gitLabVersioning .url = protectedBranchProject
285
- f .gitLabVersioning .destinationDirectory = fmt . Sprintf ( "%s/%s" , os . Getenv ( "HOME" ), "protected-branch-project" )
286
+ f .gitLabVersioning .destinationDirectory = getDestinationDirectory ( "protected-branch-project" )
286
287
repo , err := f .newGitService ()
287
288
tests .AssertNoError (t , err )
288
289
@@ -300,7 +301,7 @@ func TestNewGitUpgradeRemoteRepositoryPushToProtectedBranchError(t *testing.T) {
300
301
func TestNewGitGetCurrentVersionFromRepoWithAlphaCharacteres (t * testing.T ) {
301
302
f := getValidSetup ()
302
303
f .gitLabVersioning .url = alphaTagProject
303
- f .gitLabVersioning .destinationDirectory = fmt . Sprintf ( "%s/%s" , os . Getenv ( "HOME" ), "alpha-tag-project" )
304
+ f .gitLabVersioning .destinationDirectory = getDestinationDirectory ( "alpha-tag-project" )
304
305
repo , err := f .newGitService ()
305
306
tests .AssertNoError (t , err )
306
307
@@ -312,7 +313,7 @@ func TestNewGitGetCurrentVersionFromRepoWithAlphaCharacteres(t *testing.T) {
312
313
func TestNewGitGetCurrentVersionFromRepoWithAlphaAndNumericCharacteres (t * testing.T ) {
313
314
f := getValidSetup ()
314
315
f .gitLabVersioning .url = alphaNumericTagProject
315
- f .gitLabVersioning .destinationDirectory = fmt . Sprintf ( "%s/%s" , os . Getenv ( "HOME" ), "alpha-numeric-tag-project" )
316
+ f .gitLabVersioning .destinationDirectory = getDestinationDirectory ( "alpha-numeric-tag-project" )
316
317
repo , err := f .newGitService ()
317
318
tests .AssertNoError (t , err )
318
319
@@ -324,7 +325,7 @@ func TestNewGitGetCurrentVersionFromRepoWithAlphaAndNumericCharacteres(t *testin
324
325
func TestNewGitGetCurrentVersionFromRepoWithTagsOutOfPattern (t * testing.T ) {
325
326
f := getValidSetup ()
326
327
f .gitLabVersioning .url = tagsOutOfPatternProject
327
- f .gitLabVersioning .destinationDirectory = fmt . Sprintf ( "%s/%s" , os . Getenv ( "HOME" ), "tags-out-of-pattern-project" )
328
+ f .gitLabVersioning .destinationDirectory = getDestinationDirectory ( "tags-out-of-pattern-project" )
328
329
repo , err := f .newGitService ()
329
330
tests .AssertNoError (t , err )
330
331
@@ -337,7 +338,7 @@ func TestNewGitGetCurrentVersionFromRepoWithTagsOutOfPattern(t *testing.T) {
337
338
func TestNewGitGetCurrentVersionFromRepoWithGreatNumbersTag (t * testing.T ) {
338
339
f := getValidSetup ()
339
340
f .gitLabVersioning .url = greatNumbersTagProject
340
- f .gitLabVersioning .destinationDirectory = fmt . Sprintf ( "%s/%s" , os . Getenv ( "HOME" ), "great-numbers-tag-project" )
341
+ f .gitLabVersioning .destinationDirectory = getDestinationDirectory ( "great-numbers-tag-project" )
341
342
repo , err := f .newGitService ()
342
343
tests .AssertNoError (t , err )
343
344
@@ -346,3 +347,20 @@ func TestNewGitGetCurrentVersionFromRepoWithGreatNumbersTag(t *testing.T) {
346
347
tests .AssertEqualValues (t , "3.0.2" , result )
347
348
f .cleanLocalRepo (t )
348
349
}
350
+
351
+ func TestNewGitGetCurrentVersionFromRepoWithDisorderedTags (t * testing.T ) {
352
+ f := getValidSetup ()
353
+ f .gitLabVersioning .url = disorderedTagsProject
354
+ f .gitLabVersioning .destinationDirectory = getDestinationDirectory ("disordered-tags-prject" )
355
+ repo , err := f .newGitService ()
356
+ tests .AssertNoError (t , err )
357
+
358
+ result , err := repo .GetMostRecentTag ()
359
+ tests .AssertNil (t , err )
360
+ tests .AssertEqualValues (t , "20.1.0" , result )
361
+ f .cleanLocalRepo (t )
362
+ }
363
+
364
+ func getDestinationDirectory (repo string ) string {
365
+ return fmt .Sprintf ("%s/%s" , os .Getenv ("HOME" ), repo )
366
+ }
0 commit comments