Skip to content

Commit

Permalink
Use the conversion helper in the converter package
Browse files Browse the repository at this point in the history
  • Loading branch information
carlisia committed Aug 17, 2022
1 parent 75dd3b2 commit 02755ba
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 58 deletions.
58 changes: 29 additions & 29 deletions apis/v1alpha2/validation/httproute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
utilpointer "k8s.io/utils/pointer"

gatewayv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2"
utils "sigs.k8s.io/gateway-api/apis/v1alpha2/validation/util"
"sigs.k8s.io/gateway-api/apis/v1alpha2/converter"
)

func TestValidateHTTPRoute(t *testing.T) {
Expand All @@ -45,7 +45,7 @@ func TestValidateHTTPRoute(t *testing.T) {
Matches: []gatewayv1a2.HTTPRouteMatch{
{
Path: &gatewayv1a2.HTTPPathMatch{
Type: utils.PathMatchTypePtr("PathPrefix"),
Type: converter.PathMatchTypePtr("PathPrefix"),
Value: utilpointer.String("/"),
},
},
Expand All @@ -55,7 +55,7 @@ func TestValidateHTTPRoute(t *testing.T) {
BackendRef: gatewayv1a2.BackendRef{
BackendObjectReference: gatewayv1a2.BackendObjectReference{
Name: testService,
Port: utils.PortNumberPtr(8080),
Port: converter.PortNumberPtr(8080),
},
Weight: utilpointer.Int32(100),
},
Expand All @@ -71,7 +71,7 @@ func TestValidateHTTPRoute(t *testing.T) {
Matches: []gatewayv1a2.HTTPRouteMatch{
{
Path: &gatewayv1a2.HTTPPathMatch{
Type: utils.PathMatchTypePtr("PathPrefix"),
Type: converter.PathMatchTypePtr("PathPrefix"),
Value: utilpointer.String("/"),
},
},
Expand All @@ -82,7 +82,7 @@ func TestValidateHTTPRoute(t *testing.T) {
RequestMirror: &gatewayv1a2.HTTPRequestMirrorFilter{
BackendRef: gatewayv1a2.BackendObjectReference{
Name: testService,
Port: utils.PortNumberPtr(8081),
Port: converter.PortNumberPtr(8081),
},
},
},
Expand All @@ -97,7 +97,7 @@ func TestValidateHTTPRoute(t *testing.T) {
Matches: []gatewayv1a2.HTTPRouteMatch{
{
Path: &gatewayv1a2.HTTPPathMatch{
Type: utils.PathMatchTypePtr("PathPrefix"),
Type: converter.PathMatchTypePtr("PathPrefix"),
Value: utilpointer.String("/"),
},
},
Expand All @@ -108,7 +108,7 @@ func TestValidateHTTPRoute(t *testing.T) {
RequestMirror: &gatewayv1a2.HTTPRequestMirrorFilter{
BackendRef: gatewayv1a2.BackendObjectReference{
Name: testService,
Port: utils.PortNumberPtr(8080),
Port: converter.PortNumberPtr(8080),
},
},
},
Expand All @@ -117,7 +117,7 @@ func TestValidateHTTPRoute(t *testing.T) {
RequestMirror: &gatewayv1a2.HTTPRequestMirrorFilter{
BackendRef: gatewayv1a2.BackendObjectReference{
Name: specialService,
Port: utils.PortNumberPtr(8080),
Port: converter.PortNumberPtr(8080),
},
},
},
Expand All @@ -132,7 +132,7 @@ func TestValidateHTTPRoute(t *testing.T) {
Matches: []gatewayv1a2.HTTPRouteMatch{
{
Path: &gatewayv1a2.HTTPPathMatch{
Type: utils.PathMatchTypePtr("PathPrefix"),
Type: converter.PathMatchTypePtr("PathPrefix"),
Value: utilpointer.String("/"),
},
},
Expand All @@ -154,7 +154,7 @@ func TestValidateHTTPRoute(t *testing.T) {
RequestMirror: &gatewayv1a2.HTTPRequestMirrorFilter{
BackendRef: gatewayv1a2.BackendObjectReference{
Name: testService,
Port: utils.PortNumberPtr(8080),
Port: converter.PortNumberPtr(8080),
},
},
},
Expand All @@ -180,7 +180,7 @@ func TestValidateHTTPRoute(t *testing.T) {
Matches: []gatewayv1a2.HTTPRouteMatch{
{
Path: &gatewayv1a2.HTTPPathMatch{
Type: utils.PathMatchTypePtr("PathPrefix"),
Type: converter.PathMatchTypePtr("PathPrefix"),
Value: utilpointer.String("/"),
},
},
Expand All @@ -191,7 +191,7 @@ func TestValidateHTTPRoute(t *testing.T) {
RequestMirror: &gatewayv1a2.HTTPRequestMirrorFilter{
BackendRef: gatewayv1a2.BackendObjectReference{
Name: testService,
Port: utils.PortNumberPtr(8080),
Port: converter.PortNumberPtr(8080),
},
},
},
Expand All @@ -211,7 +211,7 @@ func TestValidateHTTPRoute(t *testing.T) {
RequestMirror: &gatewayv1a2.HTTPRequestMirrorFilter{
BackendRef: gatewayv1a2.BackendObjectReference{
Name: testService,
Port: utils.PortNumberPtr(8080),
Port: converter.PortNumberPtr(8080),
},
},
},
Expand All @@ -231,7 +231,7 @@ func TestValidateHTTPRoute(t *testing.T) {
RequestMirror: &gatewayv1a2.HTTPRequestMirrorFilter{
BackendRef: gatewayv1a2.BackendObjectReference{
Name: specialService,
Port: utils.PortNumberPtr(8080),
Port: converter.PortNumberPtr(8080),
},
},
},
Expand All @@ -246,7 +246,7 @@ func TestValidateHTTPRoute(t *testing.T) {
Matches: []gatewayv1a2.HTTPRouteMatch{
{
Path: &gatewayv1a2.HTTPPathMatch{
Type: utils.PathMatchTypePtr("PathPrefix"),
Type: converter.PathMatchTypePtr("PathPrefix"),
Value: utilpointer.String("/"),
},
},
Expand All @@ -268,7 +268,7 @@ func TestValidateHTTPRoute(t *testing.T) {
RequestMirror: &gatewayv1a2.HTTPRequestMirrorFilter{
BackendRef: gatewayv1a2.BackendObjectReference{
Name: testService,
Port: utils.PortNumberPtr(8080),
Port: converter.PortNumberPtr(8080),
},
},
},
Expand Down Expand Up @@ -453,7 +453,7 @@ func TestValidateHTTPBackendUniqueFilters(t *testing.T) {
BackendRef: gatewayv1a2.BackendRef{
BackendObjectReference: gatewayv1a2.BackendObjectReference{
Name: testService,
Port: utils.PortNumberPtr(8080),
Port: converter.PortNumberPtr(8080),
},
Weight: utilpointer.Int32(100),
},
Expand All @@ -463,7 +463,7 @@ func TestValidateHTTPBackendUniqueFilters(t *testing.T) {
RequestMirror: &gatewayv1a2.HTTPRequestMirrorFilter{
BackendRef: gatewayv1a2.BackendObjectReference{
Name: testService,
Port: utils.PortNumberPtr(8080),
Port: converter.PortNumberPtr(8080),
},
},
},
Expand All @@ -480,7 +480,7 @@ func TestValidateHTTPBackendUniqueFilters(t *testing.T) {
BackendRef: gatewayv1a2.BackendRef{
BackendObjectReference: gatewayv1a2.BackendObjectReference{
Name: testService,
Port: utils.PortNumberPtr(8080),
Port: converter.PortNumberPtr(8080),
},
},
Filters: []gatewayv1a2.HTTPRouteFilter{
Expand All @@ -489,7 +489,7 @@ func TestValidateHTTPBackendUniqueFilters(t *testing.T) {
RequestMirror: &gatewayv1a2.HTTPRequestMirrorFilter{
BackendRef: gatewayv1a2.BackendObjectReference{
Name: testService,
Port: utils.PortNumberPtr(8080),
Port: converter.PortNumberPtr(8080),
},
},
},
Expand All @@ -498,7 +498,7 @@ func TestValidateHTTPBackendUniqueFilters(t *testing.T) {
RequestMirror: &gatewayv1a2.HTTPRequestMirrorFilter{
BackendRef: gatewayv1a2.BackendObjectReference{
Name: specialService,
Port: utils.PortNumberPtr(8080),
Port: converter.PortNumberPtr(8080),
},
},
},
Expand Down Expand Up @@ -527,21 +527,21 @@ func TestValidateHTTPPathMatch(t *testing.T) {
}{{
name: "invalid httpRoute prefix",
path: &gatewayv1a2.HTTPPathMatch{
Type: utils.PathMatchTypePtr("PathPrefix"),
Type: converter.PathMatchTypePtr("PathPrefix"),
Value: utilpointer.String("/."),
},
errCount: 1,
}, {
name: "invalid httpRoute Exact",
path: &gatewayv1a2.HTTPPathMatch{
Type: utils.PathMatchTypePtr("Exact"),
Type: converter.PathMatchTypePtr("Exact"),
Value: utilpointer.String("/foo/./bar"),
},
errCount: 1,
}, {
name: "invalid httpRoute prefix",
path: &gatewayv1a2.HTTPPathMatch{
Type: utils.PathMatchTypePtr("PathPrefix"),
Type: converter.PathMatchTypePtr("PathPrefix"),
Value: utilpointer.String("/"),
},
errCount: 0,
Expand All @@ -558,7 +558,7 @@ func TestValidateHTTPPathMatch(t *testing.T) {
BackendRef: gatewayv1a2.BackendRef{
BackendObjectReference: gatewayv1a2.BackendObjectReference{
Name: gatewayv1a2.ObjectName("test"),
Port: utils.PortNumberPtr(8080),
Port: converter.PortNumberPtr(8080),
},
},
}},
Expand Down Expand Up @@ -619,7 +619,7 @@ func TestValidateHTTPHeaderMatches(t *testing.T) {
BackendRef: gatewayv1a2.BackendRef{
BackendObjectReference: gatewayv1a2.BackendObjectReference{
Name: gatewayv1a2.ObjectName("test"),
Port: utils.PortNumberPtr(8080),
Port: converter.PortNumberPtr(8080),
},
},
}},
Expand Down Expand Up @@ -683,7 +683,7 @@ func TestValidateHTTPQueryParamMatches(t *testing.T) {
BackendRef: gatewayv1a2.BackendRef{
BackendObjectReference: gatewayv1a2.BackendObjectReference{
Name: gatewayv1a2.ObjectName("test"),
Port: utils.PortNumberPtr(8080),
Port: converter.PortNumberPtr(8080),
},
},
}},
Expand Down Expand Up @@ -840,7 +840,7 @@ func TestValidateHTTPRouteTypeMatchesField(t *testing.T) {
Kind: new(gatewayv1a2.Kind),
Name: "name",
Namespace: new(gatewayv1a2.Namespace),
Port: utils.PortNumberPtr(22),
Port: converter.PortNumberPtr(22),
}},
},
errCount: 0,
Expand Down Expand Up @@ -946,7 +946,7 @@ func TestValidateHTTPRouteTypeMatchesField(t *testing.T) {
BackendRef: gatewayv1a2.BackendRef{
BackendObjectReference: gatewayv1a2.BackendObjectReference{
Name: gatewayv1a2.ObjectName("test"),
Port: utils.PortNumberPtr(8080),
Port: converter.PortNumberPtr(8080),
},
},
}},
Expand Down
Loading

0 comments on commit 02755ba

Please sign in to comment.