-
Notifications
You must be signed in to change notification settings - Fork 333
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(MeshHTTPRoute): add basic validation test
Signed-off-by: Mike Beaumont <mjboamail@gmail.com>
- Loading branch information
1 parent
f92acc8
commit cba164f
Showing
2 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
pkg/plugins/policies/meshhttproute/api/v1alpha1/v1alpha1_suite_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
41
pkg/plugins/policies/meshhttproute/api/v1alpha1/validation_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: [] | ||
`), | ||
) | ||
}) |