Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tchinmai7 committed Jan 23, 2024
1 parent dadcd59 commit 2cb398d
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions cloud/linode/loadbalancers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,12 @@ func TestCCMLoadBalancers(t *testing.T) {
{
name: "Create Load Balancer With Invalid Firewall ID",
f: testCreateNodeBalancerWithInvalidFirewall,
}, {
},
{
name: "Create Load Balancer With Valid Firewall ACL - AllowList",
f: testCreateNodeBalancerWithAllowList,
}, {
},
{
name: "Create Load Balancer With Valid Firewall ACL - DenyList",
f: testCreateNodeBalancerWithDenyList,
}, {
Expand Down Expand Up @@ -300,6 +302,19 @@ func testCreateNodeBalancer(t *testing.T, client *linodego.Client, _ *fakeAPI, a
t.Logf("actual: %v", nb.Tags)
}

_, ok := annotations[annLinodeCloudFirewallACL]
if ok {
// a firewall was configured for this
firewalls, err := client.ListNodeBalancerFirewalls(context.TODO(), nb.ID, &linodego.ListOptions{})
if err != nil {
t.Errorf("Expected nil error, got %v", err)
}

if len(firewalls) == 0 {
t.Errorf("Expected 1 firewall, got %d", len(firewalls))
}
}

defer func() { _ = lb.EnsureLoadBalancerDeleted(context.TODO(), "linodelb", svc) }()
return nil
}
Expand Down Expand Up @@ -350,9 +365,10 @@ func testCreateNodeBalancerWithAllowList(t *testing.T, client *linodego.Client,
}

err := testCreateNodeBalancer(t, client, f, annotations)
if err == nil {
if err != nil {
t.Fatalf("expected a non-nil error, got %v", err)
}

}

func testCreateNodeBalancerWithDenyList(t *testing.T, client *linodego.Client, f *fakeAPI) {
Expand Down

0 comments on commit 2cb398d

Please sign in to comment.