Skip to content

Commit c9a150e

Browse files
authored
add more integration test for model webhook(set custom createdAt) (#467)
1 parent c44a06a commit c9a150e

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

test/integration/webhook/model_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ limitations under the License.
1717
package webhook
1818

1919
import (
20+
"time"
21+
2022
"github.com/google/go-cmp/cmp/cmpopts"
2123
"github.com/onsi/ginkgo/v2"
2224
"github.com/onsi/gomega"
@@ -26,6 +28,10 @@ import (
2628
"github.com/inftyai/llmaz/test/util/wrapper"
2729
)
2830

31+
var (
32+
testTime = metav1.Date(2025, 6, 20, 10, 0, 0, 0, time.UTC)
33+
)
34+
2935
var _ = ginkgo.Describe("model default and validation", func() {
3036

3137
// Delete all the Models for each case.
@@ -75,6 +81,14 @@ var _ = ginkgo.Describe("model default and validation", func() {
7581
return wrapper.MakeModel("llama3-8b").ModelSourceWithModelID("LLM-Research/Meta-Llama-3-8B", "", "main", nil, nil).ModelSourceWithModelHub("ModelScope").FamilyName("llama3").Label(coreapi.ModelFamilyNameLabelKey, "llama3").OwnedBy("custom-owner").Obj()
7682
},
7783
}),
84+
ginkgo.Entry("set custom createdAt", &testDefaultingCase{
85+
model: func() *coreapi.OpenModel {
86+
return wrapper.MakeModel("llama3-8b").FamilyName("llama3").ModelSourceWithModelHub("ModelScope").ModelSourceWithModelID("LLM-Research/Meta-Llama-3-8B", "", "", nil, nil).CreatedAt(testTime).Obj()
87+
},
88+
wantModel: func() *coreapi.OpenModel {
89+
return wrapper.MakeModel("llama3-8b").ModelSourceWithModelID("LLM-Research/Meta-Llama-3-8B", "", "main", nil, nil).ModelSourceWithModelHub("ModelScope").FamilyName("llama3").Label(coreapi.ModelFamilyNameLabelKey, "llama3").OwnedBy(coreapi.DefaultOwnedBy).CreatedAt(testTime).Obj()
90+
},
91+
}),
7892
)
7993

8094
type testValidatingCase struct {

test/util/wrapper/model.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,11 @@ func (w *ModelWrapper) OwnedBy(ownedBy string) *ModelWrapper {
112112
return w
113113
}
114114

115+
func (w *ModelWrapper) CreatedAt(createdAt metav1.Time) *ModelWrapper {
116+
w.Spec.CreatedAt = &createdAt
117+
return w
118+
}
119+
115120
func MakeFlavor(name string) *FlavorWrapper {
116121
return &FlavorWrapper{
117122
coreapi.Flavor{

0 commit comments

Comments
 (0)