Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
146 changes: 144 additions & 2 deletions control-plane/controllers/resources/mesh_gateway_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"testing"

logrtest "github.com/go-logr/logr/testr"
"github.com/hashicorp/consul/sdk/testutil"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
appsv1 "k8s.io/api/apps/v1"
Expand All @@ -21,6 +20,9 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/client/fake"

pbmesh "github.com/hashicorp/consul/proto-public/pbmesh/v2beta1"
"github.com/hashicorp/consul/sdk/testutil"

"github.com/hashicorp/consul-k8s/control-plane/api/mesh/v2beta1"
"github.com/hashicorp/consul-k8s/control-plane/helper/test"
)
Expand Down Expand Up @@ -50,6 +52,16 @@ func TestMeshGatewayController_Reconcile(t *testing.T) {
Namespace: "consul",
Name: "mesh-gateway",
},
Spec: pbmesh.MeshGateway{
GatewayClassName: "consul",
Listeners: []*pbmesh.MeshGatewayListener{
{
Name: "wan",
Port: 8443,
Protocol: "tcp",
},
},
},
},
},
request: ctrl.Request{
Expand All @@ -73,6 +85,16 @@ func TestMeshGatewayController_Reconcile(t *testing.T) {
Namespace: "default",
Name: "mesh-gateway",
},
Spec: pbmesh.MeshGateway{
GatewayClassName: "consul",
Listeners: []*pbmesh.MeshGatewayListener{
{
Name: "wan",
Port: 8443,
Protocol: "tcp",
},
},
},
},
&corev1.ServiceAccount{
ObjectMeta: metav1.ObjectMeta{
Expand All @@ -99,6 +121,16 @@ func TestMeshGatewayController_Reconcile(t *testing.T) {
Namespace: "consul",
Name: "mesh-gateway",
},
Spec: pbmesh.MeshGateway{
GatewayClassName: "consul",
Listeners: []*pbmesh.MeshGatewayListener{
{
Name: "wan",
Port: 8443,
Protocol: "tcp",
},
},
},
},
},
request: ctrl.Request{
Expand All @@ -122,6 +154,16 @@ func TestMeshGatewayController_Reconcile(t *testing.T) {
Namespace: "default",
Name: "mesh-gateway",
},
Spec: pbmesh.MeshGateway{
GatewayClassName: "consul",
Listeners: []*pbmesh.MeshGatewayListener{
{
Name: "wan",
Port: 8443,
Protocol: "tcp",
},
},
},
},
&rbacv1.Role{
ObjectMeta: metav1.ObjectMeta{
Expand All @@ -148,6 +190,16 @@ func TestMeshGatewayController_Reconcile(t *testing.T) {
Name: "mesh-gateway",
UID: "abc123",
},
Spec: pbmesh.MeshGateway{
GatewayClassName: "consul",
Listeners: []*pbmesh.MeshGatewayListener{
{
Name: "wan",
Port: 8443,
Protocol: "tcp",
},
},
},
},
&rbacv1.Role{
ObjectMeta: metav1.ObjectMeta{
Expand Down Expand Up @@ -180,6 +232,16 @@ func TestMeshGatewayController_Reconcile(t *testing.T) {
Namespace: "consul",
Name: "mesh-gateway",
},
Spec: pbmesh.MeshGateway{
GatewayClassName: "consul",
Listeners: []*pbmesh.MeshGatewayListener{
{
Name: "wan",
Port: 8443,
Protocol: "tcp",
},
},
},
},
},
request: ctrl.Request{
Expand All @@ -203,6 +265,16 @@ func TestMeshGatewayController_Reconcile(t *testing.T) {
Namespace: "default",
Name: "mesh-gateway",
},
Spec: pbmesh.MeshGateway{
GatewayClassName: "consul",
Listeners: []*pbmesh.MeshGatewayListener{
{
Name: "wan",
Port: 8443,
Protocol: "tcp",
},
},
},
},
&rbacv1.RoleBinding{
ObjectMeta: metav1.ObjectMeta{
Expand All @@ -229,6 +301,16 @@ func TestMeshGatewayController_Reconcile(t *testing.T) {
Name: "mesh-gateway",
UID: "abc123",
},
Spec: pbmesh.MeshGateway{
GatewayClassName: "consul",
Listeners: []*pbmesh.MeshGatewayListener{
{
Name: "wan",
Port: 8443,
Protocol: "tcp",
},
},
},
},
&rbacv1.RoleBinding{
ObjectMeta: metav1.ObjectMeta{
Expand Down Expand Up @@ -261,6 +343,16 @@ func TestMeshGatewayController_Reconcile(t *testing.T) {
Namespace: "consul",
Name: "mesh-gateway",
},
Spec: pbmesh.MeshGateway{
GatewayClassName: "consul",
Listeners: []*pbmesh.MeshGatewayListener{
{
Name: "wan",
Port: 8443,
Protocol: "tcp",
},
},
},
},
},
request: ctrl.Request{
Expand All @@ -284,6 +376,16 @@ func TestMeshGatewayController_Reconcile(t *testing.T) {
Namespace: "default",
Name: "mesh-gateway",
},
Spec: pbmesh.MeshGateway{
GatewayClassName: "consul",
Listeners: []*pbmesh.MeshGatewayListener{
{
Name: "wan",
Port: 8443,
Protocol: "tcp",
},
},
},
},
&appsv1.Deployment{
ObjectMeta: metav1.ObjectMeta{
Expand All @@ -310,6 +412,16 @@ func TestMeshGatewayController_Reconcile(t *testing.T) {
Name: "mesh-gateway",
UID: "abc123",
},
Spec: pbmesh.MeshGateway{
GatewayClassName: "consul",
Listeners: []*pbmesh.MeshGatewayListener{
{
Name: "wan",
Port: 8443,
Protocol: "tcp",
},
},
},
},
&appsv1.Deployment{
ObjectMeta: metav1.ObjectMeta{
Expand Down Expand Up @@ -342,6 +454,16 @@ func TestMeshGatewayController_Reconcile(t *testing.T) {
Namespace: "consul",
Name: "mesh-gateway",
},
Spec: pbmesh.MeshGateway{
GatewayClassName: "consul",
Listeners: []*pbmesh.MeshGatewayListener{
{
Name: "wan",
Port: 8443,
Protocol: "tcp",
},
},
},
},
},
request: ctrl.Request{
Expand All @@ -365,6 +487,16 @@ func TestMeshGatewayController_Reconcile(t *testing.T) {
Namespace: "default",
Name: "mesh-gateway",
},
Spec: pbmesh.MeshGateway{
GatewayClassName: "consul",
Listeners: []*pbmesh.MeshGatewayListener{
{
Name: "wan",
Port: 8443,
Protocol: "tcp",
},
},
},
},
&corev1.Service{
ObjectMeta: metav1.ObjectMeta{
Expand All @@ -391,6 +523,16 @@ func TestMeshGatewayController_Reconcile(t *testing.T) {
Name: "mesh-gateway",
UID: "abc123",
},
Spec: pbmesh.MeshGateway{
GatewayClassName: "consul",
Listeners: []*pbmesh.MeshGatewayListener{
{
Name: "wan",
Port: 8443,
Protocol: "tcp",
},
},
},
},
&corev1.Service{
ObjectMeta: metav1.ObjectMeta{
Expand Down Expand Up @@ -444,7 +586,7 @@ func TestMeshGatewayController_Reconcile(t *testing.T) {

res, err := controller.Reconcile(context.Background(), testCase.request)
if testCase.expectedErr != nil {
//require.EqualError(t, err, testCase.expectedErr.Error())
// require.EqualError(t, err, testCase.expectedErr.Error())
Comment thread
nathancoleman marked this conversation as resolved.
require.ErrorIs(t, err, testCase.expectedErr)
} else {
require.NoError(t, err)
Expand Down