@@ -109,12 +109,22 @@ func TestSandboxClaimReconcile(t *testing.T) {
109109 },
110110 }
111111
112+ claimWithMetadata := claim .DeepCopy ()
113+ claimWithMetadata .Labels = map [string ]string {
114+ "test-label" : "test-value" ,
115+ }
116+ claimWithMetadata .Annotations = map [string ]string {
117+ "test-annotation" : "test-annotation-value" ,
118+ }
119+
112120 testCases := []struct {
113121 name string
114122 existingObjects []client.Object
115123 expectSandbox bool
116124 expectError bool
117- expectedCondition metav1.Condition
125+ expectedCondition metav1.Condition
126+ expectedLabels map [string ]string
127+ expectedAnnotations map [string ]string
118128 }{
119129 {
120130 name : "sandbox is created when a claim is made" ,
@@ -184,6 +194,23 @@ func TestSandboxClaimReconcile(t *testing.T) {
184194 Message : "Sandbox is ready" ,
185195 },
186196 },
197+ {
198+ name : "sandbox is created with labels and annotations from claim" ,
199+ existingObjects : []client.Object {template , claimWithMetadata },
200+ expectSandbox : true ,
201+ expectedCondition : metav1.Condition {
202+ Type : string (sandboxv1alpha1 .SandboxConditionReady ),
203+ Status : metav1 .ConditionFalse ,
204+ Reason : "SandboxNotReady" ,
205+ Message : "Sandbox is not ready" ,
206+ },
207+ expectedLabels : map [string ]string {
208+ "test-label" : "test-value" ,
209+ },
210+ expectedAnnotations : map [string ]string {
211+ "test-annotation" : "test-annotation-value" ,
212+ },
213+ },
187214 }
188215
189216 for _ , tc := range testCases {
@@ -221,6 +248,16 @@ func TestSandboxClaimReconcile(t *testing.T) {
221248 if diff := cmp .Diff (sandbox .Spec .PodTemplate .Spec , template .Spec .PodTemplate .Spec ); diff != "" {
222249 t .Errorf ("unexpected sandbox spec:\n %s" , diff )
223250 }
251+ if tc .expectedLabels != nil {
252+ if diff := cmp .Diff (tc .expectedLabels , sandbox .Labels ); diff != "" {
253+ t .Errorf ("unexpected sandbox labels:\n %s" , diff )
254+ }
255+ }
256+ if tc .expectedAnnotations != nil {
257+ if diff := cmp .Diff (tc .expectedAnnotations , sandbox .Annotations ); diff != "" {
258+ t .Errorf ("unexpected sandbox annotations:\n %s" , diff )
259+ }
260+ }
224261 }
225262
226263 var updatedClaim extensionsv1alpha1.SandboxClaim
0 commit comments