From ab458a0b6aee73541e90ba868b55002e1976794e Mon Sep 17 00:00:00 2001 From: sophon Date: Thu, 18 May 2023 17:36:31 +0800 Subject: [PATCH] chore: add ut --- internal/controller/builder/builder_test.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/internal/controller/builder/builder_test.go b/internal/controller/builder/builder_test.go index c3977010d..ee4bb252c 100644 --- a/internal/controller/builder/builder_test.go +++ b/internal/controller/builder/builder_test.go @@ -452,6 +452,22 @@ var _ = Describe("builder", func() { Expect(configmap).ShouldNot(BeNil()) }) + It("builds config manager sidecar container correctly", func() { + sidecarRenderedParam := &cfgcm.CfgManagerBuildParams{ + ManagerName: "cfgmgr", + CharacterType: "mysql", + SecreteName: "test-secret", + Image: constant.KBToolsImage, + Args: []string{}, + Envs: []corev1.EnvVar{}, + Volumes: []corev1.VolumeMount{}, + } + configmap, err := BuildCfgManagerContainer(sidecarRenderedParam) + Expect(err).Should(BeNil()) + Expect(configmap).ShouldNot(BeNil()) + Expect(configmap.SecurityContext).Should(BeNil()) + }) + It("builds config manager sidecar container correctly", func() { sidecarRenderedParam := &cfgcm.CfgManagerBuildParams{ ManagerName: "cfgmgr", @@ -466,6 +482,9 @@ var _ = Describe("builder", func() { configmap, err := BuildCfgManagerContainer(sidecarRenderedParam) Expect(err).Should(BeNil()) Expect(configmap).ShouldNot(BeNil()) + Expect(configmap.SecurityContext).ShouldNot(BeNil()) + Expect(configmap.SecurityContext.RunAsUser).ShouldNot(BeNil()) + Expect(*configmap.SecurityContext.RunAsUser).Should(BeEquivalentTo(int64(0))) }) })