Skip to content

Commit

Permalink
test(load-balancer): do not expect an error in the unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasmetzner committed Dec 20, 2024
1 parent 227dac9 commit 2224539
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion internal/hcops/load_balancer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1454,9 +1454,40 @@ func TestLoadBalancerOps_ReconcileHCLBServices(t *testing.T) {
{Port: 80, NodePort: 8080, Protocol: corev1.ProtocolUDP},
{Port: 443, NodePort: 8443, Protocol: corev1.ProtocolUDP},
},
initialLB: &hcloud.LoadBalancer{
ID: 4,
LoadBalancerType: &hcloud.LoadBalancerType{
MaxTargets: 25,
},
},
mock: func(_ *testing.T, tt *LBReconcilementTestCase) {
opts := hcloud.LoadBalancerAddServiceOpts{
Protocol: hcloud.LoadBalancerServiceProtocolTCP,
ListenPort: hcloud.Ptr(80),
DestinationPort: hcloud.Ptr(8080),
HealthCheck: &hcloud.LoadBalancerAddServiceOptsHealthCheck{
Protocol: hcloud.LoadBalancerServiceProtocolTCP,
Port: hcloud.Ptr(8080),
},
}
action := tt.fx.MockAddService(opts, tt.initialLB, nil)
tt.fx.ActionClient.On("WaitFor", tt.fx.Ctx, action).Return(nil)

opts = hcloud.LoadBalancerAddServiceOpts{
Protocol: hcloud.LoadBalancerServiceProtocolTCP,
ListenPort: hcloud.Ptr(443),
DestinationPort: hcloud.Ptr(8443),
HealthCheck: &hcloud.LoadBalancerAddServiceOptsHealthCheck{
Protocol: hcloud.LoadBalancerServiceProtocolTCP,
Port: hcloud.Ptr(8443),
},
}
action = tt.fx.MockAddService(opts, tt.initialLB, nil)
tt.fx.ActionClient.On("WaitFor", tt.fx.Ctx, action).Return(nil)
},
perform: func(t *testing.T, tt *LBReconcilementTestCase) {
_, err := tt.fx.LBOps.ReconcileHCLBServices(tt.fx.Ctx, tt.initialLB, tt.service)
assert.Error(t, err)
assert.NoError(t, err)
},
},
{
Expand Down

0 comments on commit 2224539

Please sign in to comment.