package controllers import ( "time" v1 "github.com/kakao/bluegreen/api/v1" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) var _ = Describe("BlueGreen controller", func() { const ( timeout = time.Second * 10 duration = time.Second * 10 interval = time.Millisecond * 250 ) Context("When creating a New BlueGreen Resource", func() { Context("When defining Blue Spec only", func() { It("Should Create a One Service and a One Deployment", func() { Expect( k8sClient.Create(ctx, &v1.BlueGreen{ ObjectMeta: metav1.ObjectMeta{ Name: "bluegreen-test", Namespace: "default", }, Spec: v1.BlueGreenSpec{ RouteTo: v1.Blue, BlueSpec: &corev1.PodSpec{ Containers: []corev1.Container{ {Name: "blue", Image: "nginx"}, }, }, }, }, ), ).Should(Succeed()) svcList := &corev1.ServiceList{} Eventually(func() bool { if err := k8sClient.List(ctx, svcList); err != nil { return false } return len(svcList.Items) != 0 }, timeout, interval).Should(BeTrue()) Expect(len(svcList.Items)).To(Equal(1)) /* More Validation Logics here */ }) }) /* More Test Scenarios here */ }) })