Skip to content

Commit

Permalink
fix: fix unit tests
Browse files Browse the repository at this point in the history
Signed-off-by: Philipp Plotnikov <[email protected]>
  • Loading branch information
Philipp-Plotnikov committed Apr 25, 2024
1 parent ff35f6f commit 936a51e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ lint:
golangci-lint run --fix

.PHONY: test
test:
go test -v ./...

# convenience target to run `mkdocs serve` using a docker container
Expand Down
12 changes: 6 additions & 6 deletions pkg/plugin/httproute.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ func (r *RpcPlugin) setHTTPRouteWeight(rollout *v1alpha1.Rollout, desiredWeight
ctx := context.TODO()
httpRouteClient := r.HTTPRouteClient
if !r.IsTest {
gatewayV1beta1 := r.GatewayAPIClientset.GatewayV1beta1()
httpRouteClient = gatewayV1beta1.HTTPRoutes(gatewayAPIConfig.Namespace)
gatewayClientv1 := r.GatewayAPIClientset.GatewayV1()
httpRouteClient = gatewayClientv1.HTTPRoutes(gatewayAPIConfig.Namespace)
}
httpRoute, err := httpRouteClient.Get(ctx, gatewayAPIConfig.HTTPRoute, metav1.GetOptions{})
if err != nil {
Expand Down Expand Up @@ -73,8 +73,8 @@ func (r *RpcPlugin) setHTTPHeaderRoute(rollout *v1alpha1.Rollout, headerRouting
httpRouteName := gatewayAPIConfig.HTTPRoute
clientset := r.TestClientset
if !r.IsTest {
gatewayV1beta1 := r.GatewayAPIClientset.GatewayV1beta1()
httpRouteClient = gatewayV1beta1.HTTPRoutes(gatewayAPIConfig.Namespace)
gatewayClientv1 := r.GatewayAPIClientset.GatewayV1()
httpRouteClient = gatewayClientv1.HTTPRoutes(gatewayAPIConfig.Namespace)
clientset = r.Clientset.CoreV1().ConfigMaps(gatewayAPIConfig.Namespace)
}
configMap, err := utils.GetOrCreateConfigMap(gatewayAPIConfig.ConfigMap, utils.CreateConfigMapOptions{
Expand Down Expand Up @@ -253,8 +253,8 @@ func (r *RpcPlugin) removeHTTPManagedRoutes(managedRouteNameList []v1alpha1.Mang
httpRouteName := gatewayAPIConfig.HTTPRoute
managedRouteMap := make(ManagedRouteMap)
if !r.IsTest {
gatewayV1beta1 := r.GatewayAPIClientset.GatewayV1beta1()
httpRouteClient = gatewayV1beta1.HTTPRoutes(gatewayAPIConfig.Namespace)
gatewayClientv1 := r.GatewayAPIClientset.GatewayV1()
httpRouteClient = gatewayClientv1.HTTPRoutes(gatewayAPIConfig.Namespace)
clientset = r.Clientset.CoreV1().ConfigMaps(gatewayAPIConfig.Namespace)
}
configMap, err := utils.GetOrCreateConfigMap(gatewayAPIConfig.ConfigMap, utils.CreateConfigMapOptions{
Expand Down
2 changes: 1 addition & 1 deletion pkg/plugin/plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func TestRunSuccessfully(t *testing.T) {
rpcPluginImp := &RpcPlugin{
LogCtx: logCtx,
IsTest: true,
HTTPRouteClient: gwFake.NewSimpleClientset(&mocks.HTTPRouteObj).GatewayV1beta1().HTTPRoutes(mocks.RolloutNamespace),
HTTPRouteClient: gwFake.NewSimpleClientset(&mocks.HTTPRouteObj).GatewayV1().HTTPRoutes(mocks.RolloutNamespace),
TCPRouteClient: gwFake.NewSimpleClientset(&mocks.TCPPRouteObj).GatewayV1alpha2().TCPRoutes(mocks.RolloutNamespace),
TestClientset: fake.NewSimpleClientset(&mocks.ConfigMapObj).CoreV1().ConfigMaps(mocks.RolloutNamespace),
}
Expand Down
11 changes: 6 additions & 5 deletions pkg/plugin/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ import (
v1 "k8s.io/client-go/kubernetes/typed/core/v1"

Check failure on line 8 in pkg/plugin/types.go

View workflow job for this annotation

GitHub Actions / Go code linting

File is not `gofmt`-ed with `-s` (gofmt)
"sigs.k8s.io/gateway-api/apis/v1alpha2"
"sigs.k8s.io/gateway-api/apis/v1beta1"
gatewayv1 "sigs.k8s.io/gateway-api/apis/v1"
gatewayAPIClientset "sigs.k8s.io/gateway-api/pkg/client/clientset/versioned"
gatewayApiv1alpha2 "sigs.k8s.io/gateway-api/pkg/client/clientset/versioned/typed/apis/v1alpha2"
gatewayApiv1beta1 "sigs.k8s.io/gateway-api/pkg/client/clientset/versioned/typed/apis/v1beta1"
gatewayApiClientv1alpha2 "sigs.k8s.io/gateway-api/pkg/client/clientset/versioned/typed/apis/v1alpha2"
gatewayApiClientv1 "sigs.k8s.io/gateway-api/pkg/client/clientset/versioned/typed/apis/v1"
)

type RpcPlugin struct {
Expand All @@ -19,10 +20,10 @@ type RpcPlugin struct {
GatewayAPIClientset *gatewayAPIClientset.Clientset
Clientset *kubernetes.Clientset
TestClientset v1.ConfigMapInterface
UpdatedHTTPRouteMock *v1beta1.HTTPRoute
UpdatedHTTPRouteMock *gatewayv1.HTTPRoute
UpdatedTCPRouteMock *v1alpha2.TCPRoute
HTTPRouteClient gatewayApiv1beta1.HTTPRouteInterface
TCPRouteClient gatewayApiv1alpha2.TCPRouteInterface
HTTPRouteClient gatewayApiClientv1.HTTPRouteInterface
TCPRouteClient gatewayApiClientv1alpha2.TCPRouteInterface
}

type GatewayAPITrafficRouting struct {
Expand Down

0 comments on commit 936a51e

Please sign in to comment.