Skip to content

Commit 018330e

Browse files
committed
adjusted and added tests
Signed-off-by: Marek Markiewka <[email protected]>
1 parent 579eaea commit 018330e

File tree

1 file changed

+55
-12
lines changed

1 file changed

+55
-12
lines changed

test/com/cloudogu/gitopsbuildlib/DeployViaGitopsTest.groovy

Lines changed: 55 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,10 @@ spec:
182182
echo "filepath is: ${args.file}, data is: ${args.data}, overwrite is: ${args.overwrite}"
183183
}
184184

185+
// deployViaGitops.metaClass.error = { String args ->
186+
// echo "${args}"
187+
// }
188+
185189
when(git.commitHashShort).thenReturn('1234abcd')
186190
}
187191

@@ -448,22 +452,23 @@ spec:
448452
void 'error on single missing mandatory field'() {
449453

450454
def gitopsConfigMissingMandatoryField = [
451-
scm : [
455+
scm: [
452456
baseUrl : 'http://scmm-scm-manager/scm',
453457
repositoryUrl: 'fluxv1/gitops',
454458
],
455-
gitopsTool : 'FLUX_V1',
456-
deployments : [
459+
application: 'app',
460+
gitopsTool: 'FLUX_V1',
461+
deployments: [
457462
sourcePath: 'k8s',
458-
plain : [
463+
plain: [
459464
updateImages: [
460465
[filename : "deployment.yaml",
461466
containerName: 'application',
462467
imageName : 'imageName']
463468
]
464469
]
465470
],
466-
stages : [
471+
stages: [
467472
staging : [deployDirectly: true],
468473
production: [deployDirectly: false],
469474
qa : []
@@ -485,7 +490,7 @@ spec:
485490

486491
def gitopsConfigMissingMandatoryField = [
487492
scm : [
488-
provider : 'SCMManager',
493+
provider : 'SCMManagerr',
489494
baseUrl : 'http://scmm-scm-manager/scm',
490495
repositoryUrl: 'fluxv1/gitops',
491496
],
@@ -513,7 +518,7 @@ spec:
513518
}
514519

515520
assertThat(
516-
helper.callStack.findAll { call -> call.methodName == "error" }.any { call ->
521+
helper.callStack.findAll { call -> println(call.methodName); call.methodName == "error" }.any { call ->
517522
callArgsToString(call).contains("[application]")
518523
}).isTrue()
519524
}
@@ -542,14 +547,52 @@ spec:
542547
}).isTrue()
543548
}
544549

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+
545588
@Test
546589
void 'error on missing tooling'() {
547590
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+
],
553596
application : 'application',
554597
gitopsTool : '',
555598
deployments : [

0 commit comments

Comments
 (0)