Fix unit tests

This commit is contained in:
Tomasz Sęk 2019-11-13 09:56:55 +01:00
parent 32a6245e0f
commit f52dc42171
No known key found for this signature in database
GPG Key ID: DC356D23F6A644D0
2 changed files with 3 additions and 2 deletions

View File

@ -59,6 +59,7 @@ func (c *Configuration) getJenkinsMasterPod() (*corev1.Pod, error) {
return currentJenkinsMasterPod, nil return currentJenkinsMasterPod, nil
} }
// IsJenkinsTerminating returns true if the Jenkins pod is terminating
func (c *Configuration) IsJenkinsTerminating(pod corev1.Pod) bool { func (c *Configuration) IsJenkinsTerminating(pod corev1.Pod) bool {
return pod.ObjectMeta.DeletionTimestamp != nil return pod.ObjectMeta.DeletionTimestamp != nil
} }

View File

@ -67,12 +67,12 @@ func TestPodRestartPrepend(t *testing.T) {
res := "test-reason" res := "test-reason"
podRestart := NewPodRestart(KubernetesSource, []string{res}) podRestart := NewPodRestart(KubernetesSource, []string{res})
assert.Equal(t, podRestart.short[0], fmt.Sprintf("Jenkins master pod restarted by: %s", res)) assert.Equal(t, fmt.Sprintf("Jenkins master pod restarted by %s: %s", KubernetesSource, res), podRestart.short[0])
}) })
t.Run("happy with multiple message", func(t *testing.T) { t.Run("happy with multiple message", func(t *testing.T) {
podRestart := NewPodRestart(KubernetesSource, []string{"first-reason", "second-reason", "third-reason"}) podRestart := NewPodRestart(KubernetesSource, []string{"first-reason", "second-reason", "third-reason"})
assert.Equal(t, podRestart.short[0], "Jenkins master pod restarted by:") assert.Equal(t, fmt.Sprintf("Jenkins master pod restarted by %s:", KubernetesSource), podRestart.short[0])
}) })
} }