@@ -182,6 +182,10 @@ spec:
182
182
echo " filepath is: ${ args.file} , data is: ${ args.data} , overwrite is: ${ args.overwrite} "
183
183
}
184
184
185
+ // deployViaGitops.metaClass.error = { String args ->
186
+ // echo "${args}"
187
+ // }
188
+
185
189
when(git. commitHashShort). thenReturn(' 1234abcd' )
186
190
}
187
191
@@ -448,22 +452,23 @@ spec:
448
452
void ' error on single missing mandatory field' () {
449
453
450
454
def gitopsConfigMissingMandatoryField = [
451
- scm : [
455
+ scm : [
452
456
baseUrl : ' http://scmm-scm-manager/scm' ,
453
457
repositoryUrl : ' fluxv1/gitops' ,
454
458
],
455
- gitopsTool : ' FLUX_V1' ,
456
- deployments : [
459
+ application : ' app' ,
460
+ gitopsTool : ' FLUX_V1' ,
461
+ deployments : [
457
462
sourcePath : ' k8s' ,
458
- plain : [
463
+ plain : [
459
464
updateImages : [
460
465
[filename : " deployment.yaml" ,
461
466
containerName : ' application' ,
462
467
imageName : ' imageName' ]
463
468
]
464
469
]
465
470
],
466
- stages : [
471
+ stages : [
467
472
staging : [deployDirectly : true ],
468
473
production : [deployDirectly : false ],
469
474
qa : []
@@ -485,7 +490,7 @@ spec:
485
490
486
491
def gitopsConfigMissingMandatoryField = [
487
492
scm : [
488
- provider : ' SCMManager ' ,
493
+ provider : ' SCMManagerr ' ,
489
494
baseUrl : ' http://scmm-scm-manager/scm' ,
490
495
repositoryUrl : ' fluxv1/gitops' ,
491
496
],
@@ -513,7 +518,7 @@ spec:
513
518
}
514
519
515
520
assertThat (
516
- helper. callStack. findAll { call -> call. methodName == " error" }. any { call ->
521
+ helper. callStack. findAll { call -> println (call . methodName); call. methodName == " error" }. any { call ->
517
522
callArgsToString(call). contains(" [application]" )
518
523
}). isTrue()
519
524
}
@@ -542,14 +547,52 @@ spec:
542
547
}). isTrue()
543
548
}
544
549
550
+ @Test
551
+ void ' error on non available scm provider' () {
552
+
553
+ def gitopsConfigMissingMandatoryField = [
554
+ scm : [
555
+ provider : ' nonValid' ,
556
+ baseUrl : ' http://scmm-scm-manager/scm' ,
557
+ repositoryUrl : ' fluxv1/gitops' ,
558
+ ],
559
+ application : ' app' ,
560
+ gitopsTool : ' FLUX_V1' ,
561
+ deployments : [
562
+ sourcePath : ' k8s' ,
563
+ plain : [
564
+ updateImages : [
565
+ [filename : " deployment.yaml" ,
566
+ containerName : ' application' ,
567
+ imageName : ' imageName' ]
568
+ ]
569
+ ]
570
+ ],
571
+ stages : [
572
+ staging : [deployDirectly : true ],
573
+ production : [deployDirectly : false ],
574
+ qa : []
575
+ ]
576
+ ]
577
+
578
+ gitRepo. use {
579
+ deployViaGitops. call(gitopsConfigMissingMandatoryField)
580
+ }
581
+
582
+ assertThat (
583
+ helper. callStack. findAll { call -> call. methodName == " error" }. any { call ->
584
+ callArgsToString(call). contains(" The given scm-provider seems to be invalid. Please choose one of the following: \' SCMManager\' ." )
585
+ }). isTrue()
586
+ }
587
+
545
588
@Test
546
589
void ' error on missing tooling' () {
547
590
def gitopsConfigMissingTooling = [
548
- scmmCredentialsId : ' scmManagerCredentials ' ,
549
- scmmConfigRepoUrl : ' configRepositoryUrl ' ,
550
- scmmPullRequestBaseUrl : ' scmmPullRequestBaseUrl ' ,
551
- scmmPullRequestRepo : ' scmmPullRequestRepo ' ,
552
- scmmPullRequestUrl : ' configRepositoryPRUrl ' ,
591
+ scm : [
592
+ provider : ' SCMManager ' ,
593
+ baseUrl : ' http://scmm-scm-manager/scm ' ,
594
+ repositoryUrl : ' fluxv1/gitops ' ,
595
+ ] ,
553
596
application : ' application' ,
554
597
gitopsTool : ' ' ,
555
598
deployments : [
0 commit comments