Skip to content
This repository has been archived by the owner on Mar 19, 2024. It is now read-only.

Commit

Permalink
fixed unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sarahalsmiller committed May 18, 2022
1 parent d99967c commit a4eaf98
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
7 changes: 6 additions & 1 deletion internal/k8s/reconciler/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,12 @@ func (g *K8sGateway) ensureDeploymentExists(ctx context.Context) error {
if err != nil {
return err
}
mutated = apigwv1alpha1.MergeDeployment(deployment, mutated, currentDeployment.Spec.Replicas)

var currentReplicas *int32
if currentDeployment != nil {
currentReplicas = currentDeployment.Spec.Replicas
}
mutated = apigwv1alpha1.MergeDeployment(deployment, mutated, currentReplicas)

if updated, err := g.client.CreateOrUpdateDeployment(ctx, mutated, func() error {
return g.client.SetControllerOwnership(g.gateway, mutated)
Expand Down
7 changes: 7 additions & 0 deletions internal/k8s/reconciler/gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,7 @@ func TestGatewayTrackSync(t *testing.T) {
Client: client,
})
gateway.gateway.Status = gateway.Status()
client.EXPECT().GetDeployment(gomock.Any(), gomock.Any()).Return(nil, nil)
client.EXPECT().CreateOrUpdateDeployment(gomock.Any(), gomock.Any(), gomock.Any()).Return(true, nil)
require.NoError(t, gateway.TrackSync(context.Background(), func() (bool, error) {
return false, nil
Expand All @@ -495,6 +496,7 @@ func TestGatewayTrackSync(t *testing.T) {
},
})

client.EXPECT().GetDeployment(gomock.Any(), gomock.Any()).Return(nil, nil)
client.EXPECT().CreateOrUpdateDeployment(gomock.Any(), gomock.Any(), gomock.Any()).Return(false, nil)
client.EXPECT().UpdateStatus(gomock.Any(), gateway.gateway).Return(nil)
require.NoError(t, gateway.TrackSync(context.Background(), func() (bool, error) {
Expand All @@ -510,6 +512,7 @@ func TestGatewayTrackSync(t *testing.T) {
}),
Client: client,
})
client.EXPECT().GetDeployment(gomock.Any(), gomock.Any()).Return(nil, nil)
client.EXPECT().CreateOrUpdateDeployment(gomock.Any(), gomock.Any(), gomock.Any()).Return(false, expected)
require.True(t, errors.Is(gateway.TrackSync(context.Background(), func() (bool, error) {
return false, nil
Expand All @@ -522,6 +525,7 @@ func TestGatewayTrackSync(t *testing.T) {
}),
Client: client,
})
client.EXPECT().GetDeployment(gomock.Any(), gomock.Any()).Return(nil, nil)
client.EXPECT().CreateOrUpdateDeployment(gomock.Any(), gomock.Any(), gomock.Any()).Return(false, nil)
client.EXPECT().UpdateStatus(gomock.Any(), gateway.gateway).Return(expected)
require.Equal(t, expected, gateway.TrackSync(context.Background(), func() (bool, error) {
Expand All @@ -535,6 +539,8 @@ func TestGatewayTrackSync(t *testing.T) {
}),
Client: client,
})

client.EXPECT().GetDeployment(gomock.Any(), gomock.Any()).Return(nil, nil)
client.EXPECT().CreateOrUpdateDeployment(gomock.Any(), gomock.Any(), gomock.Any()).Return(false, nil)
client.EXPECT().UpdateStatus(gomock.Any(), gateway.gateway).Return(nil)
require.NoError(t, gateway.TrackSync(context.Background(), func() (bool, error) {
Expand All @@ -548,6 +554,7 @@ func TestGatewayTrackSync(t *testing.T) {
}),
Client: client,
})
client.EXPECT().GetDeployment(gomock.Any(), gomock.Any()).Return(nil, nil)
client.EXPECT().CreateOrUpdateDeployment(gomock.Any(), gomock.Any(), gomock.Any()).Return(false, nil)
client.EXPECT().UpdateStatus(gomock.Any(), gateway.gateway).Return(nil)
require.NoError(t, gateway.TrackSync(context.Background(), func() (bool, error) {
Expand Down

0 comments on commit a4eaf98

Please sign in to comment.