#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

View File

@ -150,18 +150,6 @@ func GetJenkinsMasterPodBaseVolumes(jenkins *v1alpha2.Jenkins) []corev1.Volume {
return volumes 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 { func getGroovyScriptsSecretVolumeName(jenkins *v1alpha2.Jenkins) string {
return "gs-" + jenkins.Spec.GroovyScripts.Secret.Name return "gs-" + jenkins.Spec.GroovyScripts.Secret.Name
} }

View File

@ -138,9 +138,14 @@ func TestGetJenkinsMasterPodBaseVolumes(t *testing.T) {
}, },
} }
groovyExists := false groovyExists, cascExists := checkSecretVolumesPresence(jenkins)
cascExists := false
assert.True(t, groovyExists)
assert.True(t, cascExists)
})
}
func checkSecretVolumesPresence(jenkins *v1alpha2.Jenkins) (groovyExists bool, cascExists bool) {
for _, volume := range GetJenkinsMasterPodBaseVolumes(jenkins) { for _, volume := range GetJenkinsMasterPodBaseVolumes(jenkins) {
if volume.Name == ("gs-" + jenkins.Spec.GroovyScripts.Secret.Name) { if volume.Name == ("gs-" + jenkins.Spec.GroovyScripts.Secret.Name) {
groovyExists = true groovyExists = true
@ -148,8 +153,6 @@ func TestGetJenkinsMasterPodBaseVolumes(t *testing.T) {
cascExists = true cascExists = true
} }
} }
return groovyExists, cascExists
assert.True(t, groovyExists)
assert.True(t, cascExists)
})
} }