diff --git a/internal/cli/root.go b/internal/cli/root.go index 7058fc0f..e96d95bc 100644 --- a/internal/cli/root.go +++ b/internal/cli/root.go @@ -108,6 +108,11 @@ func (c *Client) metalApiConnect(httpClient *http.Client) error { configuration.Debug = checkEnvForDebug() configuration.AddDefaultHeader("X-Auth-Token", c.Token()) configuration.UserAgent = fmt.Sprintf("metal-cli/%s %s", c.Version, configuration.UserAgent) + configuration.Servers = metal.ServerConfigurations{ + metal.ServerConfiguration{ + URL: c.apiURL, + }, + } metalgoClient := metal.NewAPIClient(configuration) c.metalApiClient = metalgoClient return nil @@ -134,7 +139,7 @@ func (c *Client) Config(cmd *cobra.Command) *viper.Viper { } if err := v.ReadInConfig(); err != nil { if _, ok := err.(viper.ConfigFileNotFoundError); !ok { - panic(fmt.Errorf("Could not read config: %s", err)) + panic(fmt.Errorf("could not read config: %s", err)) } } c.cfgFile = v.ConfigFileUsed() diff --git a/test/e2e/capacitytest/capacity_test.go b/test/e2e/capacitytest/capacity_test.go index 43317ac4..81341dfe 100644 --- a/test/e2e/capacitytest/capacity_test.go +++ b/test/e2e/capacitytest/capacity_test.go @@ -13,10 +13,8 @@ import ( func TestCli_Capacity(t *testing.T) { subCommand := "capacity" - consumerToken := "" - apiURL := "" - Version := "metal" - rootClient := root.NewClient(consumerToken, apiURL, Version) + + rootClient := root.NewClient(helper.ConsumerToken, helper.URL, helper.Version) type fields struct { MainCmd *cobra.Command Outputer outputPkg.Outputer diff --git a/test/e2e/devices/devicecreateflagstest/device_create_flags_test.go b/test/e2e/devices/devicecreateflagstest/device_create_flags_test.go index d13a48d4..e9ad1cb8 100644 --- a/test/e2e/devices/devicecreateflagstest/device_create_flags_test.go +++ b/test/e2e/devices/devicecreateflagstest/device_create_flags_test.go @@ -16,10 +16,7 @@ func TestCli_Devices_Create_Flags(t *testing.T) { var deviceId string var err error subCommand := "device" - consumerToken := "" - apiURL := "" - Version := "metal" - rootClient := root.NewClient(consumerToken, apiURL, Version) + rootClient := root.NewClient(helper.ConsumerToken, helper.URL, helper.Version) type fields struct { MainCmd *cobra.Command Outputer outputPkg.Outputer @@ -39,7 +36,7 @@ func TestCli_Devices_Create_Flags(t *testing.T) { want: &cobra.Command{}, cmdFunc: func(t *testing.T, c *cobra.Command) { root := c.Root() - projectName := "metal-cli-device-create-flags" + helper.GenerateRandomString(5) + projectName := "metal-cli-" + helper.GenerateRandomString(5) + "-device-create-flags" project := helper.CreateTestProject(t, projectName) root.SetArgs([]string{subCommand, "create", "-p", project.GetId(), "-P", "m3.small.x86", "-m", "da", "-H", "metal-cli-create-flags-dev", "--operating-system", "custom_ipxe", "--always-pxe=true", "--ipxe-script-url", "https://boot.netboot.xyz/"}) diff --git a/test/e2e/devices/devicecreatetest/device_create_test.go b/test/e2e/devices/devicecreatetest/device_create_test.go index cdd5b435..a3f9de3f 100644 --- a/test/e2e/devices/devicecreatetest/device_create_test.go +++ b/test/e2e/devices/devicecreatetest/device_create_test.go @@ -16,10 +16,7 @@ func TestCli_Devices_Create(t *testing.T) { var deviceId string var err error subCommand := "device" - consumerToken := "" - apiURL := "" - Version := "metal" - rootClient := root.NewClient(consumerToken, apiURL, Version) + rootClient := root.NewClient(helper.ConsumerToken, helper.URL, helper.Version) randomId := helper.GenerateRandomString(5) type fields struct { @@ -44,7 +41,7 @@ func TestCli_Devices_Create(t *testing.T) { projectName := "metal-cli-device-create" + randomId project := helper.CreateTestProject(t, projectName) - deviceName := "metal-cli-create-dev" + randomId + deviceName := "metal-cli-" + randomId + "-create-dev" root.SetArgs([]string{subCommand, "create", "-p", project.GetId(), "-P", "m3.small.x86", "-m", "da", "-O", "ubuntu_20_04", "-H", deviceName}) out := helper.ExecuteAndCaptureOutput(t, root) diff --git a/test/e2e/devices/devicegettest/device_get_test.go b/test/e2e/devices/devicegettest/device_get_test.go index 3b5c978c..a28b52d9 100644 --- a/test/e2e/devices/devicegettest/device_get_test.go +++ b/test/e2e/devices/devicegettest/device_get_test.go @@ -13,10 +13,7 @@ import ( func TestCli_Devices_Get(t *testing.T) { subCommand := "device" - consumerToken := "" - apiURL := "" - Version := "metal" - rootClient := root.NewClient(consumerToken, apiURL, Version) + rootClient := root.NewClient(helper.ConsumerToken, helper.URL, helper.Version) type fields struct { MainCmd *cobra.Command Outputer outputPkg.Outputer @@ -36,7 +33,7 @@ func TestCli_Devices_Get(t *testing.T) { want: &cobra.Command{}, cmdFunc: func(t *testing.T, c *cobra.Command) { root := c.Root() - projectName := "metal-cli-device-get" + helper.GenerateRandomString(5) + projectName := "metal-cli-" + helper.GenerateRandomString(5) + "-device-get" project := helper.CreateTestProject(t, projectName) device := helper.CreateTestDevice(t, project.GetId(), "metal-cli-get-dev") diff --git a/test/e2e/devices/devicereinstalltest/device_reinstall_test.go b/test/e2e/devices/devicereinstalltest/device_reinstall_test.go index 12a0737c..b57dc15c 100644 --- a/test/e2e/devices/devicereinstalltest/device_reinstall_test.go +++ b/test/e2e/devices/devicereinstalltest/device_reinstall_test.go @@ -14,10 +14,7 @@ func TestCli_Devices_Update(t *testing.T) { var err error var status bool subCommand := "device" - consumerToken := "" - apiURL := "" - Version := "metal" - rootClient := root.NewClient(consumerToken, apiURL, Version) + rootClient := root.NewClient(helper.ConsumerToken, helper.URL, helper.Version) type fields struct { MainCmd *cobra.Command Outputer outputPkg.Outputer @@ -37,7 +34,7 @@ func TestCli_Devices_Update(t *testing.T) { want: &cobra.Command{}, cmdFunc: func(t *testing.T, c *cobra.Command) { root := c.Root() - projectName := "metal-cli-device-reinstall" + helper.GenerateRandomString(5) + projectName := "metal-cli-" + helper.GenerateRandomString(5) + "-device-reinstall" project := helper.CreateTestProject(t, projectName) device := helper.CreateTestDevice(t, project.GetId(), "metal-cli-reinstall-dev") status, err = helper.IsDeviceStateActive(t, device.GetId()) diff --git a/test/e2e/devices/devicestarttest/device_start_test.go b/test/e2e/devices/devicestarttest/device_start_test.go index 8c1fbb24..f64e4abb 100644 --- a/test/e2e/devices/devicestarttest/device_start_test.go +++ b/test/e2e/devices/devicestarttest/device_start_test.go @@ -13,10 +13,7 @@ import ( func TestCli_Devices_Update(t *testing.T) { subCommand := "device" - consumerToken := "" - apiURL := "" - Version := "metal" - rootClient := root.NewClient(consumerToken, apiURL, Version) + rootClient := root.NewClient(helper.ConsumerToken, helper.URL, helper.Version) type fields struct { MainCmd *cobra.Command Outputer outputPkg.Outputer @@ -36,7 +33,7 @@ func TestCli_Devices_Update(t *testing.T) { want: &cobra.Command{}, cmdFunc: func(t *testing.T, c *cobra.Command) { root := c.Root() - projectName := "metal-cli-device-start" + helper.GenerateRandomString(5) + projectName := "metal-cli-" + helper.GenerateRandomString(5) + "-device-start" project := helper.CreateTestProject(t, projectName) device := helper.CreateTestDevice(t, project.GetId(), "metal-cli-start-dev") status, err := helper.IsDeviceStateActive(t, device.GetId()) diff --git a/test/e2e/devices/devicestoptest/device_stop_test.go b/test/e2e/devices/devicestoptest/device_stop_test.go index 3e68ab10..62c5b1c3 100644 --- a/test/e2e/devices/devicestoptest/device_stop_test.go +++ b/test/e2e/devices/devicestoptest/device_stop_test.go @@ -13,10 +13,7 @@ import ( func TestCli_Devices_Update(t *testing.T) { subCommand := "device" - consumerToken := "" - apiURL := "" - Version := "metal" - rootClient := root.NewClient(consumerToken, apiURL, Version) + rootClient := root.NewClient(helper.ConsumerToken, helper.URL, helper.Version) type fields struct { MainCmd *cobra.Command Outputer outputPkg.Outputer @@ -36,7 +33,7 @@ func TestCli_Devices_Update(t *testing.T) { want: &cobra.Command{}, cmdFunc: func(t *testing.T, c *cobra.Command) { root := c.Root() - projectName := "metal-cli-device-stop" + helper.GenerateRandomString(5) + projectName := "metal-cli-" + helper.GenerateRandomString(5) + "-device-stop" project := helper.CreateTestProject(t, projectName) device := helper.CreateTestDevice(t, project.GetId(), "metal-cli-stop-dev") diff --git a/test/e2e/devices/deviceupdatetest/device_update_test.go b/test/e2e/devices/deviceupdatetest/device_update_test.go index 2471f806..12d2b5d2 100644 --- a/test/e2e/devices/deviceupdatetest/device_update_test.go +++ b/test/e2e/devices/deviceupdatetest/device_update_test.go @@ -13,10 +13,7 @@ import ( func TestCli_Devices_Update(t *testing.T) { subCommand := "device" - consumerToken := "" - apiURL := "" - Version := "metal" - rootClient := root.NewClient(consumerToken, apiURL, Version) + rootClient := root.NewClient(helper.ConsumerToken, helper.URL, helper.Version) type fields struct { MainCmd *cobra.Command Outputer outputPkg.Outputer @@ -36,7 +33,7 @@ func TestCli_Devices_Update(t *testing.T) { want: &cobra.Command{}, cmdFunc: func(t *testing.T, c *cobra.Command) { root := c.Root() - projectName := "metal-cli-device-update" + helper.GenerateRandomString(5) + projectName := "metal-cli-" + helper.GenerateRandomString(5) + "-device-update" project := helper.CreateTestProject(t, projectName) device := helper.CreateTestDevice(t, project.GetId(), "metal-cli-update-dev") diff --git a/test/e2e/events/deviceeventstest/device_event_test.go b/test/e2e/events/deviceeventstest/device_event_test.go index 9c471384..5981f010 100644 --- a/test/e2e/events/deviceeventstest/device_event_test.go +++ b/test/e2e/events/deviceeventstest/device_event_test.go @@ -13,10 +13,7 @@ import ( func TestCli_Events_Get(t *testing.T) { subCommand := "event" - consumerToken := "" - apiURL := "" - Version := "metal" - rootClient := root.NewClient(consumerToken, apiURL, Version) + rootClient := root.NewClient(helper.ConsumerToken, helper.URL, helper.Version) type fields struct { MainCmd *cobra.Command Outputer outputPkg.Outputer @@ -36,7 +33,7 @@ func TestCli_Events_Get(t *testing.T) { want: &cobra.Command{}, cmdFunc: func(t *testing.T, c *cobra.Command) { root := c.Root() - projectName := "metal-cli-device-events" + helper.GenerateRandomString(5) + projectName := "metal-cli-" + helper.GenerateRandomString(5) + "-device-events" project := helper.CreateTestProject(t, projectName) device := helper.CreateTestDevice(t, project.GetId(), "metal-cli-events-dev") status, err := helper.IsDeviceStateActive(t, device.GetId()) diff --git a/test/e2e/events/projecteventstest/project_events_test.go b/test/e2e/events/projecteventstest/project_events_test.go index e000cc37..43ef1a55 100644 --- a/test/e2e/events/projecteventstest/project_events_test.go +++ b/test/e2e/events/projecteventstest/project_events_test.go @@ -13,10 +13,7 @@ import ( func TestCli_Events_Get(t *testing.T) { subCommand := "event" - consumerToken := "" - apiURL := "" - Version := "metal" - rootClient := root.NewClient(consumerToken, apiURL, Version) + rootClient := root.NewClient(helper.ConsumerToken, helper.URL, helper.Version) type fields struct { MainCmd *cobra.Command Outputer outputPkg.Outputer @@ -37,7 +34,7 @@ func TestCli_Events_Get(t *testing.T) { cmdFunc: func(t *testing.T, c *cobra.Command) { root := c.Root() - projectName := "metal-cli-projects-events" + helper.GenerateRandomString(5) + projectName := "metal-cli-" + helper.GenerateRandomString(5) + "-projects-events" project := helper.CreateTestProject(t, projectName) root.SetArgs([]string{subCommand, "get", "-p", project.GetId()}) diff --git a/test/e2e/gateways/create_test.go b/test/e2e/gateways/create_test.go index 3de64b46..a02b2861 100644 --- a/test/e2e/gateways/create_test.go +++ b/test/e2e/gateways/create_test.go @@ -17,12 +17,9 @@ import ( func TestGateways_Create(t *testing.T) { subCommand := "gateways" - consumerToken := "" - apiURL := "" - Version := "devel" - rootClient := root.NewClient(consumerToken, apiURL, Version) - - project := helper.CreateTestProject(t, "metal-cli-gateways-create") + rootClient := root.NewClient(helper.ConsumerToken, helper.URL, helper.Version) + projectName := "metal-cli-" + helper.GenerateRandomString(5) + "-gateways-create" + project := helper.CreateTestProject(t, projectName) vlan := helper.CreateTestVLAN(t, project.GetId()) tests := []struct { diff --git a/test/e2e/gateways/delete_test.go b/test/e2e/gateways/delete_test.go index 1b407a88..330eb729 100644 --- a/test/e2e/gateways/delete_test.go +++ b/test/e2e/gateways/delete_test.go @@ -16,12 +16,9 @@ import ( func TestGateways_Delete(t *testing.T) { subCommand := "gateways" - consumerToken := "" - apiURL := "" - Version := "devel" - rootClient := root.NewClient(consumerToken, apiURL, Version) - - project := helper.CreateTestProject(t, "metal-cli-gateway-delete") + rootClient := root.NewClient(helper.ConsumerToken, helper.URL, helper.Version) + projectName := "metal-cli-" + helper.GenerateRandomString(5) + "-gateway-delete" + project := helper.CreateTestProject(t, projectName) vlan := helper.CreateTestVLAN(t, project.GetId()) diff --git a/test/e2e/gateways/retrieve_test.go b/test/e2e/gateways/retrieve_test.go index 07db5e95..715671bf 100644 --- a/test/e2e/gateways/retrieve_test.go +++ b/test/e2e/gateways/retrieve_test.go @@ -14,12 +14,9 @@ import ( func TestGateways_Retrieve(t *testing.T) { subCommand := "gateways" - consumerToken := "" - apiURL := "" - Version := "devel" - rootClient := root.NewClient(consumerToken, apiURL, Version) - - project := helper.CreateTestProject(t, "metal-cli-gateway-get") + rootClient := root.NewClient(helper.ConsumerToken, helper.URL, helper.Version) + projectName := "metal-cli-" + helper.GenerateRandomString(5) + "-gateway-get" + project := helper.CreateTestProject(t, projectName) vlan := helper.CreateTestVLAN(t, project.GetId()) diff --git a/test/e2e/ipstest/ips_get_test.go b/test/e2e/ipstest/ips_get_test.go index 0f1ef87b..81d5b46b 100644 --- a/test/e2e/ipstest/ips_get_test.go +++ b/test/e2e/ipstest/ips_get_test.go @@ -15,10 +15,7 @@ func TestCli_Ips_Get(t *testing.T) { var ipsId string var err error subCommand := "ip" - consumerToken := "" - apiURL := "" - Version := "metal" - rootClient := root.NewClient(consumerToken, apiURL, Version) + rootClient := root.NewClient(helper.ConsumerToken, helper.URL, helper.Version) type fields struct { MainCmd *cobra.Command Outputer outputPkg.Outputer @@ -41,7 +38,7 @@ func TestCli_Ips_Get(t *testing.T) { t.Skip("Skipping this test because someCondition is true") } root := c.Root() - projectName := "metal-cli-ips-get" + helper.GenerateRandomString(5) + projectName := "metal-cli-" + helper.GenerateRandomString(5) + "-ips-get" project := helper.CreateTestProject(t, projectName) ipsId, err = helper.CreateTestIps(t, project.GetId(), 1, "public_ipv4") if len(ipsId) != 0 { diff --git a/test/e2e/ipstest/ips_request_test.go b/test/e2e/ipstest/ips_request_test.go index aec6a565..644022fc 100644 --- a/test/e2e/ipstest/ips_request_test.go +++ b/test/e2e/ipstest/ips_request_test.go @@ -13,10 +13,7 @@ import ( func TestCli_Vlan_Create(t *testing.T) { subCommand := "ip" - consumerToken := "" - apiURL := "" - Version := "metal" - rootClient := root.NewClient(consumerToken, apiURL, Version) + rootClient := root.NewClient(helper.ConsumerToken, helper.URL, helper.Version) type fields struct { MainCmd *cobra.Command Outputer outputPkg.Outputer @@ -39,7 +36,7 @@ func TestCli_Vlan_Create(t *testing.T) { t.Skip("Skipping temporarily for now") } root := c.Root() - projectName := "metal-cli-ips-get" + helper.GenerateRandomString(5) + projectName := "metal-cli-" + helper.GenerateRandomString(5) + "-ips-request-get" project := helper.CreateTestProject(t, projectName) root.SetArgs([]string{subCommand, "request", "-p", project.GetId(), "-t", "public_ipv4", "-m", "da", "-q", "4"}) diff --git a/test/e2e/metrotest/metro_test.go b/test/e2e/metrotest/metro_test.go index 7d34d9d5..664142e5 100644 --- a/test/e2e/metrotest/metro_test.go +++ b/test/e2e/metrotest/metro_test.go @@ -13,10 +13,7 @@ import ( func TestCli_Metros(t *testing.T) { subCommand := "metros" - consumerToken := "" - apiURL := "" - Version := "metal" - rootClient := root.NewClient(consumerToken, apiURL, Version) + rootClient := root.NewClient(helper.ConsumerToken, helper.URL, helper.Version) type fields struct { MainCmd *cobra.Command Outputer outputPkg.Outputer diff --git a/test/e2e/organizationtest/organization_test.go b/test/e2e/organizationtest/organization_test.go index 1ed839b9..15bf1838 100644 --- a/test/e2e/organizationtest/organization_test.go +++ b/test/e2e/organizationtest/organization_test.go @@ -6,16 +6,14 @@ import ( root "github.com/equinix/metal-cli/internal/cli" "github.com/equinix/metal-cli/internal/organizations" outputPkg "github.com/equinix/metal-cli/internal/outputs" + "github.com/equinix/metal-cli/test/helper" "github.com/spf13/cobra" "github.com/stretchr/testify/assert" ) func TestCli_Organization(t *testing.T) { subCommand := "organization" - consumerToken := "" - apiURL := "" - Version := "metal" - rootClient := root.NewClient(consumerToken, apiURL, Version) + rootClient := root.NewClient(helper.ConsumerToken, helper.URL, helper.Version) type fields struct { MainCmd *cobra.Command Outputer outputPkg.Outputer diff --git a/test/e2e/ostest/os_test.go b/test/e2e/ostest/os_test.go index 509156fd..3402430b 100644 --- a/test/e2e/ostest/os_test.go +++ b/test/e2e/ostest/os_test.go @@ -13,10 +13,7 @@ import ( func TestCli_OperatingSystem(t *testing.T) { subCommand := "operating-systems" - consumerToken := "" - apiURL := "" - Version := "metal" - rootClient := root.NewClient(consumerToken, apiURL, Version) + rootClient := root.NewClient(helper.ConsumerToken, helper.URL, helper.Version) type fields struct { MainCmd *cobra.Command Outputer outputPkg.Outputer diff --git a/test/e2e/plantest/plan_test.go b/test/e2e/plantest/plan_test.go index 28cf3aae..6fece238 100644 --- a/test/e2e/plantest/plan_test.go +++ b/test/e2e/plantest/plan_test.go @@ -13,14 +13,8 @@ import ( ) func TestCli_Plans(t *testing.T) { - if testing.Short() { - t.Skip("skipping test in short mode.") - } subCommand := "plans" - consumerToken := "" - apiURL := "" - Version := "metal" - rootClient := root.NewClient(consumerToken, apiURL, Version) + rootClient := root.NewClient(helper.ConsumerToken, helper.URL, helper.Version) type fields struct { MainCmd *cobra.Command Outputer outputPkg.Outputer diff --git a/test/e2e/ports/convert_test.go b/test/e2e/ports/convert_test.go index ca01dd99..54722023 100644 --- a/test/e2e/ports/convert_test.go +++ b/test/e2e/ports/convert_test.go @@ -16,10 +16,7 @@ import ( func TestPorts_Convert(t *testing.T) { subCommand := "port" - consumerToken := "" - apiURL := "" - Version := "devel" - rootClient := root.NewClient(consumerToken, apiURL, Version) + rootClient := root.NewClient(helper.ConsumerToken, helper.URL, helper.Version) _, device := helper.SetupProjectAndDevice(t, "metal-cli-port-convert") diff --git a/test/e2e/ports/retrieve_test.go b/test/e2e/ports/retrieve_test.go index f815770b..8f244b7c 100644 --- a/test/e2e/ports/retrieve_test.go +++ b/test/e2e/ports/retrieve_test.go @@ -14,10 +14,7 @@ import ( func TestPorts_Retrieve(t *testing.T) { subCommand := "port" - consumerToken := "" - apiURL := "" - Version := "devel" - rootClient := root.NewClient(consumerToken, apiURL, Version) + rootClient := root.NewClient(helper.ConsumerToken, helper.URL, helper.Version) _, device := helper.SetupProjectAndDevice(t, "metal-cli-port-get") diff --git a/test/e2e/ports/vlans_test.go b/test/e2e/ports/vlans_test.go index b94bd1a6..0957367d 100644 --- a/test/e2e/ports/vlans_test.go +++ b/test/e2e/ports/vlans_test.go @@ -16,10 +16,7 @@ import ( func TestPorts_VLANs(t *testing.T) { subCommand := "port" - consumerToken := "" - apiURL := "" - Version := "devel" - rootClient := root.NewClient(consumerToken, apiURL, Version) + rootClient := root.NewClient(helper.ConsumerToken, helper.URL, helper.Version) project, device := helper.SetupProjectAndDevice(t, "metal-cli-port-vlan") diff --git a/test/e2e/projecttest/project_test.go b/test/e2e/projecttest/project_test.go index 59c4bf7d..04015a57 100644 --- a/test/e2e/projecttest/project_test.go +++ b/test/e2e/projecttest/project_test.go @@ -14,10 +14,7 @@ import ( func TestCli_Project_Tests(t *testing.T) { subCommand := "project" - consumerToken := "" - apiURL := "" - Version := "metal" - rootClient := root.NewClient(consumerToken, apiURL, Version) + rootClient := root.NewClient(helper.ConsumerToken, helper.URL, helper.Version) randName := helper.GenerateRandomString(32) type fields struct { diff --git a/test/e2e/sshtest/ssh_test.go b/test/e2e/sshtest/ssh_test.go index 70e7eef1..3923ebae 100644 --- a/test/e2e/sshtest/ssh_test.go +++ b/test/e2e/sshtest/ssh_test.go @@ -13,10 +13,7 @@ import ( func TestCli_SshKey(t *testing.T) { subCommand := "ssh-key" - consumerToken := "" - apiURL := "" - Version := "metal" - rootClient := root.NewClient(consumerToken, apiURL, Version) + rootClient := root.NewClient(helper.ConsumerToken, helper.URL, helper.Version) type fields struct { MainCmd *cobra.Command Outputer outputPkg.Outputer diff --git a/test/e2e/usertest/user_test.go b/test/e2e/usertest/user_test.go index 0194d3e0..d3f5521e 100644 --- a/test/e2e/usertest/user_test.go +++ b/test/e2e/usertest/user_test.go @@ -13,10 +13,7 @@ import ( func TestCli_Users(t *testing.T) { subCommand := "user" - consumerToken := "" - apiURL := "" - Version := "metal" - rootClient := root.NewClient(consumerToken, apiURL, Version) + rootClient := root.NewClient(helper.ConsumerToken, helper.URL, helper.Version) type fields struct { MainCmd *cobra.Command Outputer outputPkg.Outputer diff --git a/test/e2e/vlan/vlan_creat_test.go b/test/e2e/vlan/vlan_creat_test.go index 502fa28b..e6c823d5 100644 --- a/test/e2e/vlan/vlan_creat_test.go +++ b/test/e2e/vlan/vlan_creat_test.go @@ -14,10 +14,7 @@ import ( func TestCli_Vlan_Create(t *testing.T) { var err error subCommand := "vlan" - consumerToken := "" - apiURL := "" - Version := "metal" - rootClient := root.NewClient(consumerToken, apiURL, Version) + rootClient := root.NewClient(helper.ConsumerToken, helper.URL, helper.Version) type fields struct { MainCmd *cobra.Command Outputer outputPkg.Outputer @@ -37,7 +34,7 @@ func TestCli_Vlan_Create(t *testing.T) { want: &cobra.Command{}, cmdFunc: func(t *testing.T, c *cobra.Command) { root := c.Root() - projectName := "metal-cli-vlan-create-pro" + helper.GenerateRandomString(5) + projectName := "metal-cli-" + helper.GenerateRandomString(5) + "-vlan-create-pro" project := helper.CreateTestProject(t, projectName) if err != nil { t.Error(err) diff --git a/test/e2e/vlan/vlan_delete_test.go b/test/e2e/vlan/vlan_delete_test.go index bf442509..8860b63b 100644 --- a/test/e2e/vlan/vlan_delete_test.go +++ b/test/e2e/vlan/vlan_delete_test.go @@ -15,10 +15,7 @@ func TestCli_Vlan_Clean(t *testing.T) { var vlanId string var err error subCommand := "vlan" - consumerToken := "" - apiURL := "" - Version := "metal" - rootClient := root.NewClient(consumerToken, apiURL, Version) + rootClient := root.NewClient(helper.ConsumerToken, helper.URL, helper.Version) type fields struct { MainCmd *cobra.Command Outputer outputPkg.Outputer @@ -38,7 +35,7 @@ func TestCli_Vlan_Clean(t *testing.T) { want: &cobra.Command{}, cmdFunc: func(t *testing.T, c *cobra.Command) { root := c.Root() - projectName := "metal-cli-vlan-get-pro" + helper.GenerateRandomString(5) + projectName := "metal-cli-" + helper.GenerateRandomString(5) + "-vlan-get-pro" project := helper.CreateTestProject(t, projectName) if err != nil { t.Error(err) diff --git a/test/e2e/vlan/vlan_get_test.go b/test/e2e/vlan/vlan_get_test.go index c27053d7..3e1cbd69 100644 --- a/test/e2e/vlan/vlan_get_test.go +++ b/test/e2e/vlan/vlan_get_test.go @@ -15,10 +15,7 @@ func TestCli_Vlan_Get(t *testing.T) { var vlanId string var err error subCommand := "vlan" - consumerToken := "" - apiURL := "" - Version := "metal" - rootClient := root.NewClient(consumerToken, apiURL, Version) + rootClient := root.NewClient(helper.ConsumerToken, helper.URL, helper.Version) type fields struct { MainCmd *cobra.Command Outputer outputPkg.Outputer @@ -38,7 +35,7 @@ func TestCli_Vlan_Get(t *testing.T) { want: &cobra.Command{}, cmdFunc: func(t *testing.T, c *cobra.Command) { root := c.Root() - projectName := "metal-cli-vlan-delete-pro" + helper.GenerateRandomString(5) + projectName := "metal-cli-" + helper.GenerateRandomString(5) + "-vlan-delete-pro" project := helper.CreateTestProject(t, projectName) if err != nil { t.Error(err) diff --git a/test/helper/helper.go b/test/helper/helper.go index 15ab62aa..03671044 100644 --- a/test/helper/helper.go +++ b/test/helper/helper.go @@ -17,6 +17,12 @@ import ( "github.com/spf13/cobra" ) +const ( + ConsumerToken = "" + URL = "https://api.equinix.com/metal/v1/" + Version = "metal" +) + func TestClient() *metalv1.APIClient { configuration := metalv1.NewConfiguration() configuration.AddDefaultHeader("X-Auth-Token", os.Getenv("METAL_AUTH_TOKEN"))