Skip to content

Commit

Permalink
Fix tests that rely on deprecated behavior removed in newer sdk versions
Browse files Browse the repository at this point in the history
  • Loading branch information
ddelnano committed Oct 9, 2023
1 parent a0df9d5 commit ae80b5f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 2 additions & 0 deletions xoa/data_source_user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,13 @@ data "xenorchestra_user" "user" {
func testAccXenorchestraDataSourceUserInCurrentSessionConfig(username string) string {
return fmt.Sprintf(`
provider "xenorchestra" {
alias = "user_in_session"
username = "%s"
password = "password"
}
data "xenorchestra_user" "user" {
provider = xenorchestra.user_in_session
username = "%s"
search_in_session = true
}
Expand Down
14 changes: 8 additions & 6 deletions xoa/resource_xenorchestra_vm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -480,17 +480,17 @@ func TestAccXenorchestraVm_ensureVmsInResourceSetsCanBeUpdatedByNonAdminUsers(t
// Create a VM using the resource set from the previous step
{
Config: providerCredentials(accUser.Email, accUserPassword) +
testAccVmManagedResourceSetConfig(vmName),
testAccVmManagedResourceSetWithDescriptionConfig(vmName, "", "provider = xenorchestra.non_admin_user"),
},
// Verify that the non admin user can update the VM. This is the main assertion of the test
{
Config: providerCredentials(accUser.Email, accUserPassword) +
testAccVmManagedResourceSetWithDescriptionConfig(vmName, "new description"),
testAccVmManagedResourceSetWithDescriptionConfig(vmName, "new description", "provider = xenorchestra.non_admin_user"),
},
// Re-run with the admin user so that it can delete the resource set and cloud config
{
Config: providerCredentials(adminUser, adminPassword) +
testAccVmManagedResourceSetConfig(vmName),
testAccVmManagedResourceSetWithDescriptionConfig(vmName, "", "provider = xenorchestra.non_admin_user"),
},
},
})
Expand Down Expand Up @@ -2362,20 +2362,22 @@ resource "xenorchestra_vm" "bar" {
func providerCredentials(username, password string) string {
return fmt.Sprintf(`
provider "xenorchestra" {
alias = "non_admin_user"
username = "%s"
password = "%s"
}
`, username, password)
}

func testAccVmManagedResourceSetConfig(vmName string) string {
return testAccVmManagedResourceSetWithDescriptionConfig(vmName, "")
return testAccVmManagedResourceSetWithDescriptionConfig(vmName, "", "")
}

func testAccVmManagedResourceSetWithDescriptionConfig(vmName, nameDescription string) string {
func testAccVmManagedResourceSetWithDescriptionConfig(vmName, nameDescription string, providerAlias string) string {
return testAccCloudConfigConfig(fmt.Sprintf("vm-template-%s", vmName), "template") + testAccVmResourceSet(vmName) + fmt.Sprintf(`
resource "xenorchestra_vm" "bar" {
%s
memory_max = 4295000000
cpus = 1
cloud_config = "${xenorchestra_cloud_config.bar.template}"
Expand All @@ -2393,7 +2395,7 @@ resource "xenorchestra_vm" "bar" {
size = 10001317888
}
}
`, vmName, nameDescription, accDefaultSr.Id)
`, providerAlias, vmName, nameDescription, accDefaultSr.Id)
}

func testAccVmResourceSet(vmName string) string {
Expand Down

0 comments on commit ae80b5f

Please sign in to comment.