Skip to content

Commit

Permalink
test(MeshHTTPRoute): add basic validation test
Browse files Browse the repository at this point in the history
Signed-off-by: Mike Beaumont <mjboamail@gmail.com>
  • Loading branch information
michaelbeaumont committed Jan 10, 2023
1 parent f92acc8 commit cba164f
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package v1alpha1_test

import (
"testing"

"github.com/kumahq/kuma/pkg/test"
)

func TestPlugin(t *testing.T) {
test.RunSpecs(t, "MeshHTTPRoute")
}
41 changes: 41 additions & 0 deletions pkg/plugins/policies/meshhttproute/api/v1alpha1/validation_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package v1alpha1_test

import (
. "github.com/onsi/ginkgo/v2"

"github.com/kumahq/kuma/pkg/core/validators"
api "github.com/kumahq/kuma/pkg/plugins/policies/meshhttproute/api/v1alpha1"

. "github.com/kumahq/kuma/pkg/test/resources"
)

var _ = Describe("validation", func() {
DescribeErrorCases(
api.NewMeshHTTPRouteResource,
ErrorCase("basic error",
validators.Violation{
Field: `spec.targetRef.kind`,
Message: `value is not supported`,
}, `
type: MeshHTTPRoute
mesh: mesh-1
name: route-1
targetRef:
kind: BlahBlah
name: frontend
to: []
`),
)
DescribeValidCases(
api.NewMeshHTTPRouteResource,
Entry("accepts valid resource", `
type: MeshHTTPRoute
mesh: mesh-1
name: route-1
targetRef:
kind: MeshService
name: frontend
to: []
`),
)
})

0 comments on commit cba164f

Please sign in to comment.