@@ -17,11 +17,13 @@ limitations under the License.
1717package webhook
1818
1919import (
20+ "github.com/google/go-cmp/cmp/cmpopts"
2021 "github.com/onsi/ginkgo/v2"
2122 "github.com/onsi/gomega"
2223 corev1 "k8s.io/api/core/v1"
2324 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2425
26+ coreapi "github.com/inftyai/llmaz/api/core/v1alpha1"
2527 inferenceapi "github.com/inftyai/llmaz/api/inference/v1alpha1"
2628 "github.com/inftyai/llmaz/test/util/wrapper"
2729)
@@ -47,7 +49,6 @@ var _ = ginkgo.Describe("playground default and validation", func() {
4749 playground func () * inferenceapi.Playground
4850 failed bool
4951 }
50- // TODO: Add more testCases to cover updating.
5152 ginkgo .DescribeTable ("test validating" ,
5253 func (tc * testValidatingCase ) {
5354 if tc .failed {
@@ -93,4 +94,26 @@ var _ = ginkgo.Describe("playground default and validation", func() {
9394 failed : true ,
9495 }),
9596 )
97+
98+ type testDefaultingCase struct {
99+ playground func () * inferenceapi.Playground
100+ wantPlayground func () * inferenceapi.Playground
101+ }
102+ ginkgo .DescribeTable ("test validating" ,
103+ func (tc * testDefaultingCase ) {
104+ playground := tc .playground ()
105+ gomega .Expect (k8sClient .Create (ctx , playground )).To (gomega .Succeed ())
106+ gomega .Expect (playground ).To (gomega .BeComparableTo (tc .wantPlayground (),
107+ cmpopts .IgnoreTypes (inferenceapi.PlaygroundStatus {}),
108+ cmpopts .IgnoreFields (metav1.ObjectMeta {}, "UID" , "ResourceVersion" , "Generation" , "CreationTimestamp" , "ManagedFields" )))
109+ },
110+ ginkgo .Entry ("defaulting label with modelClaim" , & testDefaultingCase {
111+ playground : func () * inferenceapi.Playground {
112+ return wrapper .MakePlayground ("playground" , ns .Name ).ModelClaim ("llama3-8b" ).Replicas (1 ).Obj ()
113+ },
114+ wantPlayground : func () * inferenceapi.Playground {
115+ return wrapper .MakePlayground ("playground" , ns .Name ).ModelClaim ("llama3-8b" ).Replicas (1 ).Label (coreapi .ModelNameLabelKey , "llama3-8b" ).Obj ()
116+ },
117+ }),
118+ )
96119})
0 commit comments