Skip to content

Commit

Permalink
ingress-controller/mock: switch to uber mock (#939)
Browse files Browse the repository at this point in the history
  • Loading branch information
calebdoxsey authored Apr 16, 2024
1 parent 883ba78 commit 5e833f1
Show file tree
Hide file tree
Showing 11 changed files with 66 additions and 51 deletions.
15 changes: 10 additions & 5 deletions controllers/ingress/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"context"
"testing"

"github.com/golang/mock/gomock"
"github.com/stretchr/testify/assert"
"go.uber.org/mock/gomock"
networkingv1 "k8s.io/api/networking/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand Down Expand Up @@ -44,7 +44,8 @@ func TestManagingIngressClass(t *testing.T) {
networkingv1.Ingress{
Spec: networkingv1.IngressSpec{
IngressClassName: &pomeriumIngressClass,
}},
},
},
[]networkingv1.IngressClass{{
ObjectMeta: metav1.ObjectMeta{
Name: pomeriumIngressClass,
Expand All @@ -61,7 +62,8 @@ func TestManagingIngressClass(t *testing.T) {
Spec: networkingv1.IngressSpec{
IngressClassName: &otherIngressClass,
},
}, []networkingv1.IngressClass{{
},
[]networkingv1.IngressClass{{
ObjectMeta: metav1.ObjectMeta{
Name: otherIngressClass,
},
Expand All @@ -79,7 +81,8 @@ func TestManagingIngressClass(t *testing.T) {
IngressClassAnnotationKey: pomeriumIngressClass,
},
},
}, []networkingv1.IngressClass{{
},
[]networkingv1.IngressClass{{
ObjectMeta: metav1.ObjectMeta{
Name: pomeriumIngressClass,
},
Expand All @@ -90,7 +93,9 @@ func TestManagingIngressClass(t *testing.T) {
true,
},
{
"default ingress", networkingv1.Ingress{}, []networkingv1.IngressClass{{
"default ingress",
networkingv1.Ingress{},
[]networkingv1.IngressClass{{
ObjectMeta: metav1.ObjectMeta{
Name: pomeriumIngressClass,
Annotations: map[string]string{
Expand Down
55 changes: 30 additions & 25 deletions controllers/mock/client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions controllers/mock/mock.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Package mock_test contains mock clients for testing
package mock_test

//go:generate go run github.com/golang/mock/mockgen -package mock_test -destination client.go sigs.k8s.io/controller-runtime/pkg/client Client
//go:generate go run github.com/golang/mock/mockgen -package mock_test -destination pomerium_ingress_reconciler.go github.com/pomerium/ingress-controller/pomerium IngressReconciler
//go:generate go run github.com/golang/mock/mockgen -package mock_test -destination pomerium_config_reconciler.go github.com/pomerium/ingress-controller/pomerium ConfigReconciler
//go:generate go run go.uber.org/mock/mockgen -package mock_test -destination client.go sigs.k8s.io/controller-runtime/pkg/client Client
//go:generate go run go.uber.org/mock/mockgen -package mock_test -destination pomerium_ingress_reconciler.go github.com/pomerium/ingress-controller/pomerium IngressReconciler
//go:generate go run go.uber.org/mock/mockgen -package mock_test -destination pomerium_config_reconciler.go github.com/pomerium/ingress-controller/pomerium ConfigReconciler
9 changes: 7 additions & 2 deletions controllers/mock/pomerium_config_reconciler.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 9 additions & 4 deletions controllers/mock/pomerium_ingress_reconciler.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion controllers/settings/fetch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"context"
"testing"

"github.com/golang/mock/gomock"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.uber.org/mock/gomock"
"google.golang.org/protobuf/proto"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down
2 changes: 1 addition & 1 deletion controllers/settings/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import (
"testing"

"github.com/go-logr/zapr"
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
"go.uber.org/mock/gomock"
"go.uber.org/zap/zaptest"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down
1 change: 1 addition & 0 deletions cspell.config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ words:
- databroker
- deepcopy
- envtest
- mockgen
- pomerium
- protobuf
- oidc
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,22 @@ require (
github.com/go-logr/logr v1.4.1
github.com/go-logr/zapr v1.3.0
github.com/go-playground/validator/v10 v10.19.0
github.com/golang/mock v1.6.0
github.com/google/go-cmp v0.6.0
github.com/google/uuid v1.6.0
github.com/gosimple/slug v1.14.0
github.com/hashicorp/go-multierror v1.1.1
github.com/iancoleman/strcase v0.3.0
github.com/martinlindhe/base36 v1.1.1
github.com/open-policy-agent/opa v0.63.0
github.com/pomerium/csrf v1.7.0
github.com/pomerium/pomerium v0.25.1
github.com/rs/zerolog v1.32.0
github.com/sergi/go-diff v1.3.1
github.com/spf13/cobra v1.8.0
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.18.2
github.com/stretchr/testify v1.9.0
go.uber.org/mock v0.4.0
go.uber.org/zap v1.27.0
golang.org/x/sync v0.6.0
google.golang.org/grpc v1.62.1
Expand Down Expand Up @@ -152,7 +153,6 @@ require (
github.com/philhofer/fwd v1.0.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/pomerium/csrf v1.7.0 // indirect
github.com/pomerium/datasource v0.18.2-0.20221108160055-c6134b5ed524 // indirect
github.com/pomerium/webauthn v0.0.0-20221118023040-00a9c430578b // indirect
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
Expand Down
Loading

0 comments on commit 5e833f1

Please sign in to comment.