diff --git a/fwprovider/tests/datasource_node_test.go b/fwprovider/tests/datasource_node_test.go index 75264928d..aa61b5a67 100644 --- a/fwprovider/tests/datasource_node_test.go +++ b/fwprovider/tests/datasource_node_test.go @@ -7,7 +7,6 @@ package tests import ( - "context" "fmt" "testing" @@ -17,12 +16,14 @@ import ( func TestAccDatasourceNode(t *testing.T) { t.Parallel() + te := initTestEnvironment(t) + tests := []struct { name string steps []resource.TestStep }{ {"read node attributes", []resource.TestStep{{ - Config: fmt.Sprintf(`data "proxmox_virtual_environment_node" "test" { node_name = "%s" }`, accTestNodeName), + Config: fmt.Sprintf(`data "proxmox_virtual_environment_node" "test" { node_name = "%s" }`, te.nodeName), Check: resource.ComposeTestCheckFunc( testResourceAttributesSet("data.proxmox_virtual_environment_node.test", []string{ "cpu_count", @@ -37,14 +38,12 @@ func TestAccDatasourceNode(t *testing.T) { }}}, } - accProviders := testAccMuxProviders(context.Background(), t) - for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { t.Parallel() resource.Test(t, resource.TestCase{ - ProtoV6ProviderFactories: accProviders, + ProtoV6ProviderFactories: te.accProviders, Steps: tt.steps, }) }) diff --git a/fwprovider/tests/resource_vm_test.go b/fwprovider/tests/resource_vm_test.go index e467b6eda..5cc7bf8f4 100644 --- a/fwprovider/tests/resource_vm_test.go +++ b/fwprovider/tests/resource_vm_test.go @@ -99,30 +99,28 @@ func TestAccResourceVM(t *testing.T) { }, { "update cpu block", []resource.TestStep{{ - Config: ` - resource "proxmox_virtual_environment_vm" "test_vm5" { - node_name = "pve" + Config: fmt.Sprintf(`resource "proxmox_virtual_environment_vm" "test_vm5" { + node_name = "%s" started = false cpu { cores = 2 } - }`, + }`, te.nodeName), Check: resource.ComposeTestCheckFunc( testResourceAttributes("proxmox_virtual_environment_vm.test_vm5", map[string]string{ "cpu.0.sockets": "1", }), ), }, { - Config: ` - resource "proxmox_virtual_environment_vm" "test_vm5" { - node_name = "pve" + Config: fmt.Sprintf(`resource "proxmox_virtual_environment_vm" "test_vm5" { + node_name = "%s" started = false cpu { cores = 1 } - }`, + }`, te.nodeName), Check: resource.ComposeTestCheckFunc( testResourceAttributes("proxmox_virtual_environment_vm.test_vm5", map[string]string{ "cpu.0.sockets": "1", @@ -132,30 +130,28 @@ func TestAccResourceVM(t *testing.T) { }, { "update memory block", []resource.TestStep{{ - Config: ` - resource "proxmox_virtual_environment_vm" "test_vm6" { - node_name = "pve" + Config: fmt.Sprintf(`resource "proxmox_virtual_environment_vm" "test_vm6" { + node_name = "%s" started = false memory { dedicated = 2048 } - }`, + }`, te.nodeName), Check: resource.ComposeTestCheckFunc( testResourceAttributes("proxmox_virtual_environment_vm.test_vm6", map[string]string{ "memory.0.dedicated": "2048", }), ), }, { - Config: ` - resource "proxmox_virtual_environment_vm" "test_vm6" { - node_name = "pve" + Config: fmt.Sprintf(`resource "proxmox_virtual_environment_vm" "test_vm6" { + node_name = "%s" started = false memory { dedicated = 1024 } - }`, + }`, te.nodeName), Check: resource.ComposeTestCheckFunc( testResourceAttributes("proxmox_virtual_environment_vm.test_vm6", map[string]string{ "memory.0.dedicated": "1024", @@ -178,18 +174,18 @@ func TestAccResourceVM(t *testing.T) { } func TestAccResourceVMInitialization(t *testing.T) { - providerConfig := getProviderConfig(t) + te := initTestEnvironment(t) tests := []struct { name string step []resource.TestStep }{ {"initialization works with cloud-init config provided over SCSI interface", []resource.TestStep{{ - Config: providerConfig + ` + Config: te.providerConfig + fmt.Sprintf(` resource "proxmox_virtual_environment_file" "cloud_config" { content_type = "snippets" datastore_id = "local" - node_name = "pve" + node_name = "%[1]s" source_raw { data = <