Add validate function to crd resource and do validate before creation/update (#580)
This commit is contained in:
+11
-4
@@ -24,6 +24,7 @@ import (
|
||||
"net/http"
|
||||
"os"
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -69,9 +70,8 @@ func assertNotFoundFailure(err error, name string) {
|
||||
|
||||
func assertCronSpecFails(err error) {
|
||||
assert(err != nil, "using an invalid cron spec must fail")
|
||||
fe, ok := err.(fission.Error)
|
||||
assert(ok, "error must be a fission Error")
|
||||
assert(fe.Code == fission.ErrorInvalidArgument, "error must be a invalid argument error")
|
||||
ok := strings.Contains(err.Error(), "not a valid cron spec")
|
||||
assert(ok, "invalid cron spec must fail")
|
||||
}
|
||||
|
||||
func TestFunctionApi(t *testing.T) {
|
||||
@@ -82,10 +82,16 @@ func TestFunctionApi(t *testing.T) {
|
||||
},
|
||||
Spec: fission.FunctionSpec{
|
||||
Environment: fission.EnvironmentReference{
|
||||
Name: "nodejs",
|
||||
Name: "nodejs",
|
||||
Namespace: metav1.NamespaceDefault,
|
||||
},
|
||||
Package: fission.FunctionPackageRef{
|
||||
FunctionName: "xxx",
|
||||
PackageRef: fission.PackageRef{
|
||||
Namespace: metav1.NamespaceDefault,
|
||||
Name: "xxx",
|
||||
ResourceVersion: "12345",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -142,6 +148,7 @@ func TestHTTPTriggerApi(t *testing.T) {
|
||||
Namespace: metav1.NamespaceDefault,
|
||||
},
|
||||
Spec: fission.HTTPTriggerSpec{
|
||||
Method: http.MethodGet,
|
||||
RelativeURL: "/hello",
|
||||
FunctionReference: fission.FunctionReference{
|
||||
Type: fission.FunctionReferenceTypeFunctionName,
|
||||
|
||||
Reference in New Issue
Block a user