diff --git a/internal/webhook/appwrapper_webhook_test.go b/internal/webhook/appwrapper_webhook_test.go index e308defc..5cb7205d 100644 --- a/internal/webhook/appwrapper_webhook_test.go +++ b/internal/webhook/appwrapper_webhook_test.go @@ -41,6 +41,23 @@ var _ = Describe("AppWrapper Webhook Tests", func() { Expect(k8sClient.Delete(ctx, aw)).To(Succeed()) }) + It("Default queue name is set", func() { + aw := toAppWrapper(pod(100)) + + Expect(k8sClient.Create(ctx, aw)).To(Succeed()) + Expect(aw.Labels[QueueNameLabel]).Should(BeIdenticalTo(defaultQueueName), "aw should be labeled with the default queue name") + Expect(k8sClient.Delete(ctx, aw)).To(Succeed()) + }) + + It("Provided queue name is not overridden by default queue name", func() { + aw := toAppWrapper(pod(100)) + aw.Labels = utilmaps.MergeKeepFirst(map[string]string{QueueNameLabel: userProvidedQueueName}, aw.Labels) + + Expect(k8sClient.Create(ctx, aw)).To(Succeed()) + Expect(aw.Labels[QueueNameLabel]).Should(BeIdenticalTo(userProvidedQueueName), "queue name should not be overridden") + Expect(k8sClient.Delete(ctx, aw)).To(Succeed()) + }) + It("User name and ID are set", func() { aw := toAppWrapper(pod(100)) aw.Labels = utilmaps.MergeKeepFirst(map[string]string{AppWrapperUsernameLabel: "bad", AppWrapperUserIDLabel: "bad"}, aw.Labels) diff --git a/internal/webhook/suite_test.go b/internal/webhook/suite_test.go index 94763aec..c3ed18af 100644 --- a/internal/webhook/suite_test.go +++ b/internal/webhook/suite_test.go @@ -62,6 +62,8 @@ var cancel context.CancelFunc const limitedUserName = "limited-user" const limitedUserID = "8da0fcfe-6d7f-4f44-b433-d91d22cc1b8c" +const defaultQueueName = "default-queue" +const userProvidedQueueName = "user-queue" func TestControllers(t *testing.T) { RegisterFailHandler(Fail) @@ -157,7 +159,9 @@ var _ = BeforeSuite(func() { }) Expect(err).NotTo(HaveOccurred()) - err = (&AppWrapperWebhook{Config: config.NewAppWrapperConfig()}).SetupWebhookWithManager(mgr) + conf := config.NewAppWrapperConfig() + conf.QueueName = defaultQueueName // add default queue name + err = (&AppWrapperWebhook{Config: conf}).SetupWebhookWithManager(mgr) Expect(err).NotTo(HaveOccurred()) //+kubebuilder:scaffold:webhook