File: nodebalancer_config_vpc_test.go

package info (click to toggle)
golang-github-linode-linodego 1.55.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 13,112 kB
  • sloc: makefile: 96; sh: 52; python: 24
file content (49 lines) | stat: -rw-r--r-- 1,519 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package integration

import (
	"context"
	"testing"

	"github.com/stretchr/testify/require"
)

func TestNodeBalancerVPCConfig_List(t *testing.T) {
	client, nodebalancer, _, _, teardown, err := setupNodeBalancerWithVPC(t, "fixtures/TestNodeBalancerVpcConfig_List")
	if err != nil {
		t.Errorf("Error setting up nodebalancer: %s", err)
	}
	defer teardown()

	configs, err := client.ListNodeBalancerVPCConfigs(context.Background(), nodebalancer.ID, nil)
	if err != nil {
		t.Errorf("Error listing nodebalancer VPC configs: %s", err)
	}

	// We expect the list to be not empty and have at least one VPC config
	require.NotEmpty(t, configs)
	require.Len(t, configs, 1)
}

func TestNodeBalancerVPCConfig_Get(t *testing.T) {
	client, nodebalancer, _, _, teardown, err := setupNodeBalancerWithVPC(t, "fixtures/TestNodeBalancerVpcConfig_Get")
	if err != nil {
		t.Errorf("Error setting up nodebalancer: %s", err)
	}
	defer teardown()

	// Get the VPC config list for the nodebalancer (should only have one)
	configs, err := client.ListNodeBalancerVPCConfigs(context.Background(), nodebalancer.ID, nil)
	if err != nil {
		t.Errorf("Error listing nodebalancer VPC configs: %s", err)
	}
	require.NotEmpty(t, configs)
	require.Len(t, configs, 1)

	// Get the VPC config by ID
	config, err := client.GetNodeBalancerVPCConfig(context.Background(), nodebalancer.ID, configs[0].ID)
	if err != nil {
		t.Errorf("Error getting nodebalancer VPC config: %s", err)
	}
	require.NotNil(t, config)
	require.Equal(t, configs[0].ID, config.ID)
}