Skip to content

Commit

Permalink
Update fvt and add string check util
Browse files Browse the repository at this point in the history
Signed-off-by: Rafael Vasquez <[email protected]>
  • Loading branch information
rafvasq committed Mar 13, 2024
1 parent 910bb0c commit a3b9869
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions fvt/predictor/predictor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1052,8 +1052,8 @@ var _ = Describe("Invalid Predictors", func() {
// modify the object with an unrecognized model type
SetString(predictorObject, "invalidModelType", "spec", "modelType", "name")

// remove runtime field for Triton-FIL predictors for this test
if GetString(predictorObject, "spec", "runtime", "name") == "triton-2.x" {
// remove runtime field for predictors that have a runtime spec for this test
if CheckIfStringExists(predictorObject, "spec", "runtime", "name") {
SetString(predictorObject, "", "spec", "runtime", "name")
}

Expand Down
6 changes: 6 additions & 0 deletions fvt/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@ func GetString(obj *unstructured.Unstructured, fieldPath ...string) string {
return value
}

func CheckIfStringExists(obj *unstructured.Unstructured, fieldPath ...string) bool {
_, exists, err := unstructured.NestedString(obj.Object, fieldPath...)
Expect(err).ToNot(HaveOccurred())
return exists
}

func GetSlice(obj *unstructured.Unstructured, fieldPath ...string) ([]interface{}, bool) {
value, exists, err := unstructured.NestedSlice(obj.Object, fieldPath...)
Expect(err).ToNot(HaveOccurred())
Expand Down

0 comments on commit a3b9869

Please sign in to comment.