#96 Small improvements in tests

This commit is contained in:
Jakub Al-Khalili
2019-09-12 15:22:00 +02:00
parent e8277cc8a0
commit 9763ea5899
2 changed files with 13 additions and 22 deletions
@@ -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
}