summaryrefslogtreecommitdiff
path: root/test/e2e/generate_kube_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'test/e2e/generate_kube_test.go')
-rw-r--r--test/e2e/generate_kube_test.go47
1 files changed, 19 insertions, 28 deletions
diff --git a/test/e2e/generate_kube_test.go b/test/e2e/generate_kube_test.go
index 62482598a..cfa264de2 100644
--- a/test/e2e/generate_kube_test.go
+++ b/test/e2e/generate_kube_test.go
@@ -137,12 +137,12 @@ var _ = Describe("Podman generate kube", func() {
// Separate out the Service and Pod yaml
arr := strings.Split(string(kube.Out.Contents()), "---")
- Expect(len(arr)).To(Equal(2))
+ Expect(arr).To(HaveLen(2))
svc := new(v1.Service)
err := yaml.Unmarshal([]byte(arr[0]), svc)
Expect(err).To(BeNil())
- Expect(len(svc.Spec.Ports)).To(Equal(1))
+ Expect(svc.Spec.Ports).To(HaveLen(1))
Expect(svc.Spec.Ports[0].TargetPort.IntValue()).To(Equal(3890))
pod := new(v1.Pod)
@@ -324,7 +324,7 @@ var _ = Describe("Podman generate kube", func() {
pod := new(v1.Pod)
err := yaml.Unmarshal(kube.Out.Contents(), pod)
Expect(err).To(BeNil())
- Expect(len(pod.Spec.HostAliases)).To(Equal(2))
+ Expect(pod.Spec.HostAliases).To(HaveLen(2))
Expect(pod.Spec.HostAliases[0].IP).To(Equal(testIP))
Expect(pod.Spec.HostAliases[1].IP).To(Equal(testIP))
})
@@ -340,12 +340,12 @@ var _ = Describe("Podman generate kube", func() {
// Separate out the Service and Pod yaml
arr := strings.Split(string(kube.Out.Contents()), "---")
- Expect(len(arr)).To(Equal(2))
+ Expect(arr).To(HaveLen(2))
svc := new(v1.Service)
err := yaml.Unmarshal([]byte(arr[0]), svc)
Expect(err).To(BeNil())
- Expect(len(svc.Spec.Ports)).To(Equal(1))
+ Expect(svc.Spec.Ports).To(HaveLen(1))
Expect(svc.Spec.Ports[0].TargetPort.IntValue()).To(Equal(4000))
Expect(svc.Spec.Ports[0].Protocol).To(Equal(v1.ProtocolUDP))
@@ -504,8 +504,8 @@ var _ = Describe("Podman generate kube", func() {
Expect(err).To(BeNil())
containers := pod.Spec.Containers
- Expect(len(containers)).To(Equal(1))
- Expect(len(containers[0].Ports)).To(Equal(1))
+ Expect(containers).To(HaveLen(1))
+ Expect(containers[0].Ports).To(HaveLen(1))
Expect(containers[0].Ports[0].Protocol).To(Equal(v1.ProtocolUDP))
})
@@ -606,9 +606,7 @@ var _ = Describe("Podman generate kube", func() {
pod := new(v1.Pod)
err = yaml.Unmarshal(b, pod)
Expect(err).To(BeNil())
- val, found := pod.Annotations[define.BindMountPrefix+vol1]
- Expect(found).To(BeTrue(), "pod.Annotations["+vol1+"]")
- Expect(val).To(HaveSuffix("z"))
+ Expect(pod.Annotations).To(HaveKeyWithValue(define.BindMountPrefix+vol1, HaveSuffix("z")))
rm := podmanTest.Podman([]string{"pod", "rm", "-t", "0", "-f", "test1"})
rm.WaitWithDefaultTimeout()
@@ -643,7 +641,7 @@ var _ = Describe("Podman generate kube", func() {
err := yaml.Unmarshal(kube.Out.Contents(), pod)
Expect(err).To(BeNil())
- Expect(len(pod.Spec.Volumes)).To(Equal(2))
+ Expect(pod.Spec.Volumes).To(HaveLen(2))
})
@@ -841,7 +839,7 @@ var _ = Describe("Podman generate kube", func() {
Expect(err).To(BeNil())
containers := pod.Spec.Containers
- Expect(len(containers)).To(Equal(1))
+ Expect(containers).To(HaveLen(1))
Expect(containers[0].Command).To(Equal([]string{"/bin/sleep"}))
Expect(containers[0].Args).To(Equal([]string{"10s"}))
@@ -863,8 +861,8 @@ var _ = Describe("Podman generate kube", func() {
Expect(err).To(BeNil())
containers := pod.Spec.Containers
- Expect(len(containers)).To(Equal(1))
- Expect(len(containers[0].Command)).To(Equal(0))
+ Expect(containers).To(HaveLen(1))
+ Expect(containers[0].Command).To(BeEmpty())
cmd := []string{"echo", "hi"}
session = podmanTest.Podman(append([]string{"create", "--name", "test1", ALPINE}, cmd...))
@@ -882,7 +880,7 @@ var _ = Describe("Podman generate kube", func() {
Expect(err).To(BeNil())
containers = pod.Spec.Containers
- Expect(len(containers)).To(Equal(1))
+ Expect(containers).To(HaveLen(1))
Expect(containers[0].Command).To(Equal(cmd))
})
@@ -917,7 +915,7 @@ ENTRYPOINT ["sleep"]`
Expect(err).To(BeNil())
containers := pod.Spec.Containers
- Expect(len(containers)).To(Equal(1))
+ Expect(containers).To(HaveLen(1))
Expect(containers[0].Args).To(Equal([]string{"10s"}))
session = podmanTest.Podman([]string{"create", "--pod", "new:testpod-2", "--entrypoint", "echo", image, "hello"})
@@ -935,7 +933,7 @@ ENTRYPOINT ["sleep"]`
Expect(err).To(BeNil())
containers = pod.Spec.Containers
- Expect(len(containers)).To(Equal(1))
+ Expect(containers).To(HaveLen(1))
Expect(containers[0].Command).To(Equal([]string{"echo"}))
Expect(containers[0].Args).To(Equal([]string{"hello"}))
})
@@ -955,7 +953,7 @@ ENTRYPOINT ["sleep"]`
Expect(err).To(BeNil())
containers := pod.Spec.Containers
- Expect(len(containers)).To(Equal(1))
+ Expect(containers).To(HaveLen(1))
Expect(containers[0].SecurityContext.Capabilities).To(BeNil())
// Now make sure we can also `play` it.
@@ -1071,9 +1069,7 @@ USER test1`
err := yaml.Unmarshal(kube.Out.Contents(), pod)
Expect(err).To(BeNil())
- v, ok := pod.GetAnnotations()["io.containers.autoupdate/top"]
- Expect(ok).To(Equal(true))
- Expect(v).To(Equal("local"))
+ Expect(pod.GetAnnotations()).To(HaveKeyWithValue("io.containers.autoupdate/top", "local"))
})
It("podman generate kube on pod with auto update labels in all containers", func() {
@@ -1100,13 +1096,8 @@ USER test1`
Expect(pod.Spec.Containers[1].WorkingDir).To(Equal("/root"))
for _, ctr := range []string{"top1", "top2"} {
- v, ok := pod.GetAnnotations()["io.containers.autoupdate/"+ctr]
- Expect(ok).To(Equal(true))
- Expect(v).To(Equal("registry"))
-
- v, ok = pod.GetAnnotations()["io.containers.autoupdate.authfile/"+ctr]
- Expect(ok).To(Equal(true))
- Expect(v).To(Equal("/some/authfile.json"))
+ Expect(pod.GetAnnotations()).To(HaveKeyWithValue("io.containers.autoupdate/"+ctr, "registry"))
+ Expect(pod.GetAnnotations()).To(HaveKeyWithValue("io.containers.autoupdate.authfile/"+ctr, "/some/authfile.json"))
}
})
})