Skip to content

Commit a57125c

Browse files
committed
Test for bad PVC specification
Signed-off-by: Mike McKiernan <[email protected]>
1 parent 7f8ed8e commit a57125c

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

internal/controller/nimcache_controller_test.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,29 @@ var _ = Describe("NIMCache Controller", func() {
109109
return client.Get(ctx, pvcName, pvc)
110110
}, time.Second*10).Should(Succeed())
111111
})
112+
113+
It("should return an error if the PVC size is not specified", func() {
114+
ctx := context.TODO()
115+
NIMCache := &appsv1alpha1.NIMCache{
116+
ObjectMeta: metav1.ObjectMeta{
117+
Name: "test-nimcache",
118+
Namespace: "default",
119+
},
120+
Spec: appsv1alpha1.NIMCacheSpec{
121+
Source: appsv1alpha1.NIMSource{NGC: &appsv1alpha1.NGCSource{ModelPuller: "test-container", PullSecret: "my-secret"}},
122+
Storage: appsv1alpha1.Storage{PVC: appsv1alpha1.PersistentVolumeClaim{Create: ptr.To[bool](true), StorageClass: "standard"}},
123+
},
124+
Status: appsv1alpha1.NIMCacheStatus{
125+
State: appsv1alpha1.NimCacheStatusNotReady,
126+
},
127+
}
128+
Expect(client.Create(ctx, NIMCache)).To(Succeed())
129+
130+
// Reconcile the resource
131+
_, err := reconciler.reconcileNIMCache(ctx, NIMCache)
132+
Expect(err).To(HaveOccurred())
133+
Expect(err.Error()).To(ContainSubstring("failed to parse size for pvc creation"))
134+
})
112135
})
113136

114137
Context("When the Job completes", func() {

0 commit comments

Comments
 (0)