mirror of
https://github.com/jenkinsci/kubernetes-operator.git
synced 2026-10-01 13:41:12 +02:00
#96 Small improvements in tests
This commit is contained in:
@@ -150,18 +150,6 @@ func GetJenkinsMasterPodBaseVolumes(jenkins *v1alpha2.Jenkins) []corev1.Volume {
|
||||
return volumes
|
||||
}
|
||||
|
||||
func checkSecretVolumesPresence(jenkins *v1alpha2.Jenkins) (groovyExists bool, cascExists bool) {
|
||||
for _, volume := range GetJenkinsMasterPodBaseVolumes(jenkins) {
|
||||
if volume.Name == ("gs-" + jenkins.Spec.GroovyScripts.Secret.Name) {
|
||||
groovyExists = true
|
||||
} else if volume.Name == ("casc-" + jenkins.Spec.ConfigurationAsCode.Secret.Name) {
|
||||
cascExists = true
|
||||
}
|
||||
}
|
||||
|
||||
return groovyExists, cascExists
|
||||
}
|
||||
|
||||
func getGroovyScriptsSecretVolumeName(jenkins *v1alpha2.Jenkins) string {
|
||||
return "gs-" + jenkins.Spec.GroovyScripts.Secret.Name
|
||||
}
|
||||
|
||||
@@ -138,18 +138,21 @@ func TestGetJenkinsMasterPodBaseVolumes(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
groovyExists := false
|
||||
cascExists := false
|
||||
|
||||
for _, volume := range GetJenkinsMasterPodBaseVolumes(jenkins) {
|
||||
if volume.Name == ("gs-" + jenkins.Spec.GroovyScripts.Secret.Name) {
|
||||
groovyExists = true
|
||||
} else if volume.Name == ("casc-" + jenkins.Spec.ConfigurationAsCode.Secret.Name) {
|
||||
cascExists = true
|
||||
}
|
||||
}
|
||||
groovyExists, cascExists := checkSecretVolumesPresence(jenkins)
|
||||
|
||||
assert.True(t, groovyExists)
|
||||
assert.True(t, cascExists)
|
||||
})
|
||||
}
|
||||
|
||||
func checkSecretVolumesPresence(jenkins *v1alpha2.Jenkins) (groovyExists bool, cascExists bool) {
|
||||
for _, volume := range GetJenkinsMasterPodBaseVolumes(jenkins) {
|
||||
if volume.Name == ("gs-" + jenkins.Spec.GroovyScripts.Secret.Name) {
|
||||
groovyExists = true
|
||||
} else if volume.Name == ("casc-" + jenkins.Spec.ConfigurationAsCode.Secret.Name) {
|
||||
cascExists = true
|
||||
}
|
||||
}
|
||||
return groovyExists, cascExists
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user