Skip to content

Commit

Permalink
test: unit test for lb reconcilation
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasmetzner committed Nov 20, 2024
1 parent 67c46a8 commit 1364d19
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions internal/hcops/load_balancer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1286,6 +1286,33 @@ func TestLoadBalancerOps_ReconcileHCLBTargets(t *testing.T) {
},
cfg: config.HCCMConfiguration{LoadBalancer: config.LoadBalancerConfiguration{DisableIPv6: true}},
},
{
name: "provider id does not have one of the the expected prefixes",
k8sNodes: []*corev1.Node{
{Spec: corev1.NodeSpec{ProviderID: "hcloud://1"}},
{Spec: corev1.NodeSpec{ProviderID: "mycloud://2"}},
},
initialLB: &hcloud.LoadBalancer{
ID: 5,
Targets: []hcloud.LoadBalancerTarget{
{
Type: hcloud.LoadBalancerTargetTypeServer,
Server: &hcloud.LoadBalancerTargetServer{Server: &hcloud.Server{ID: 1}},
},
},
LoadBalancerType: &hcloud.LoadBalancerType{
MaxTargets: 2,
},
},
mock: func(_ *testing.T, _ *LBReconcilementTestCase) {
// Nothing to mock because no action will be taken besides emitting an event
},
perform: func(t *testing.T, tt *LBReconcilementTestCase) {
changed, err := tt.fx.LBOps.ReconcileHCLBTargets(tt.fx.Ctx, tt.initialLB, tt.service, tt.k8sNodes)
assert.NoError(t, err)
assert.False(t, changed)
},
},
{
name: "enable use of private network via default",
cfg: config.HCCMConfiguration{
Expand Down

0 comments on commit 1364d19

Please sign in to comment.