Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce generic OpenAPI entity cleanup for tests #348

Merged
merged 8 commits into from
Jan 19, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
BUGS FIXED:
* Made IPAddress field for IPAddresses struct to array [#350](https://github.com/vmware/go-vcloud-director/pull/350)

IMPROVEMENTS:
* Introduce generic OpenAPI entity cleanup for tests [348](https://github.com/vmware/go-vcloud-director/pull/348)

## 2.10.0 (December 18, 2020)
lvirbalas marked this conversation as resolved.
Show resolved Hide resolved

* Added functions to retrieve and use VCD version `client.GetVcdVersion`, `client.GetVcdShortVersion`, `client.GetVcdFullVersion`, `client.VersionEqualOrGreater` [#339](https://github.com/vmware/go-vcloud-director/pull/339)
Expand Down
8 changes: 4 additions & 4 deletions govcd/access_control_catalog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (vcd *TestVCD) Test_AdminCatalogAccessControl(check *C) {
adminCatalog, err := adminorg.CreateCatalog(catalogName, catalogName)
check.Assert(err, IsNil)
check.Assert(adminCatalog, NotNil)
AddToCleanupList(catalogName, "catalog", vcd.config.VCD.Org, check.TestName())
AddToCleanupList(catalogName, "catalog", vcd.config.VCD.Org, check.TestName(), "")
vcd.testCatalogAccessControl(adminorg, adminCatalog, check.TestName(), catalogName, check)

orgInfo, err := adminCatalog.getOrgInfo()
Expand Down Expand Up @@ -75,7 +75,7 @@ func (vcd *TestVCD) Test_CatalogAccessControl(check *C) {
adminCatalog, err := adminorg.CreateCatalog(catalogName, catalogName)
check.Assert(err, IsNil)
check.Assert(adminCatalog, NotNil)
AddToCleanupList(catalogName, "catalog", vcd.config.VCD.Org, check.TestName())
AddToCleanupList(catalogName, "catalog", vcd.config.VCD.Org, check.TestName(), "")
catalog, err := org.GetCatalogByName(catalogName, true)
check.Assert(err, IsNil)
vcd.testCatalogAccessControl(adminorg, catalog, check.TestName(), catalogName, check)
Expand Down Expand Up @@ -113,7 +113,7 @@ func (vcd *TestVCD) testCatalogAccessControl(adminOrg *AdminOrg, catalog accessC
check.Assert(err, IsNil)
newOrg, err = vcd.client.GetAdminOrgByName(orgName)
check.Assert(err, IsNil)
AddToCleanupList(orgName, "org", "", testName)
AddToCleanupList(orgName, "org", "", testName, "")
defer func() {
if testVerbose {
fmt.Printf("deleting %s\n", orgName)
Expand All @@ -139,7 +139,7 @@ func (vcd *TestVCD) testCatalogAccessControl(adminOrg *AdminOrg, catalog accessC
})
check.Assert(err, IsNil)
check.Assert(users[i].user, NotNil)
AddToCleanupList(users[i].name, "user", vcd.config.VCD.Org, testName)
AddToCleanupList(users[i].name, "user", vcd.config.VCD.Org, testName, "")
}
defer func() {
for i := 0; i < len(users); i++ {
Expand Down
4 changes: 2 additions & 2 deletions govcd/access_control_vapp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func (vcd *TestVCD) Test_VappAccessControl(check *C) {
vapp, err := makeEmptyVapp(vdc, vappName)
check.Assert(err, IsNil)
check.Assert(vapp, NotNil)
AddToCleanupList(vappName, "vapp", vcd.config.VCD.Org+"|"+vcd.config.VCD.Vdc, "Test_VappAccessControl")
AddToCleanupList(vappName, "vapp", vcd.config.VCD.Org+"|"+vcd.config.VCD.Vdc, "Test_VappAccessControl", "")

checkEmpty := func() {
settings, err := vapp.GetAccessControl(vappTenantContext)
Expand All @@ -73,7 +73,7 @@ func (vcd *TestVCD) Test_VappAccessControl(check *C) {
})
check.Assert(err, IsNil)
check.Assert(users[i].user, NotNil)
AddToCleanupList(users[i].name, "user", vcd.config.VCD.Org, "Test_VappAccessControl")
AddToCleanupList(users[i].name, "user", vcd.config.VCD.Org, "Test_VappAccessControl", "")
}

// Clean up environment
Expand Down
2 changes: 1 addition & 1 deletion govcd/adminorg_administration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func (vcd *TestVCD) Test_LDAP_Configuration(check *C) {
gotSettings, err := org.LdapConfigure(ldapSettings)
check.Assert(err, IsNil)

AddToCleanupList("LDAP-configuration", "orgLdapSettings", org.AdminOrg.Name, check.TestName())
AddToCleanupList("LDAP-configuration", "orgLdapSettings", org.AdminOrg.Name, check.TestName(), "")

check.Assert(ldapSettings.CustomOrgLdapSettings.GroupAttributes, DeepEquals, gotSettings.CustomOrgLdapSettings.GroupAttributes)
check.Assert(ldapSettings.CustomOrgLdapSettings.UserAttributes, DeepEquals, gotSettings.CustomOrgLdapSettings.UserAttributes)
Expand Down
9 changes: 4 additions & 5 deletions govcd/adminorg_ldap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func configureLdapForOrg(vcd *TestVCD, check *C, ldapHostIp string) {
check.Assert(err, IsNil)

fmt.Println(" Done")
AddToCleanupList("LDAP-configuration", "orgLdapSettings", org.AdminOrg.Name, check.TestName())
AddToCleanupList("LDAP-configuration", "orgLdapSettings", org.AdminOrg.Name, check.TestName(), "")
}

// createLdapServer spawns a vApp and photon OS VM. Using customization script it starts a testing
Expand Down Expand Up @@ -202,7 +202,7 @@ func createLdapServer(vcd *TestVCD, check *C, directNetworkName string) (string,
check.Assert(err, IsNil)
// vApp was created - adding it to cleanup list (using prepend to remove it before direct
// network removal)
PrependToCleanupList(vAppName, "vapp", "", check.TestName())
PrependToCleanupList(vAppName, "vapp", "", check.TestName(), "")
// Wait until vApp becomes configurable
initialVappStatus, err := vapp.GetStatus()
check.Assert(err, IsNil)
Expand Down Expand Up @@ -238,7 +238,7 @@ func createLdapServer(vcd *TestVCD, check *C, directNetworkName string) (string,
check.Assert(err, IsNil)

// Must be deleted before vApp to avoid IP leak
PrependToCleanupList(ldapVm.VM.Name, "vm", vAppName, check.TestName())
PrependToCleanupList(ldapVm.VM.Name, "vm", vAppName, check.TestName(), "")

// Got VM - ensure that TCP port for ldap service is open and reachable
ldapHostIp := ldapVm.VM.NetworkConnectionSection.NetworkConnection[0].IPAddress
Expand Down Expand Up @@ -292,8 +292,7 @@ func createDirectNetwork(vcd *TestVCD, check *C) string {
}
check.Assert(task.Task.HREF, Not(Equals), "")

AddToCleanupList(networkName,
"network", vcd.org.Org.Name+"|"+vcd.vdc.Vdc.Name, check.TestName())
AddToCleanupList(networkName, "network", vcd.org.Org.Name+"|"+vcd.vdc.Vdc.Name, check.TestName(), "")

err = task.WaitInspectTaskCompletion(LogTask, 10)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion govcd/adminorg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func (vcd *TestVCD) Test_FindAdminCatalogRecords(check *C) {
catalogName := "catalogForQuery"
adminCatalog, err := adminOrg.CreateCatalog(catalogName, "catalogForQueryDescription")
check.Assert(err, IsNil)
AddToCleanupList(catalogName, "catalog", vcd.config.VCD.Org, check.TestName())
AddToCleanupList(catalogName, "catalog", vcd.config.VCD.Org, check.TestName(), "")
check.Assert(adminCatalog.AdminCatalog.Name, Equals, catalogName)

// just imitate wait
Expand Down
2 changes: 1 addition & 1 deletion govcd/adminvdc_nsxt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func (vcd *TestVCD) Test_CreateNsxtOrgVdc(check *C) {
check.Assert(vdc, NotNil)
check.Assert(err, IsNil)

AddToCleanupList(vdcConfiguration.Name, "vdc", vcd.org.Org.Name, check.TestName())
AddToCleanupList(vdcConfiguration.Name, "vdc", vcd.org.Org.Name, check.TestName(), "")

adminVdc, err := adminOrg.GetAdminVDCByName(vdcConfiguration.Name, true)
check.Assert(err, IsNil)
Expand Down
5 changes: 3 additions & 2 deletions govcd/adminvdc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ package govcd

import (
"fmt"
"math"

"github.com/vmware/go-vcloud-director/v2/types/v56"
. "gopkg.in/check.v1"
"math"
)

// Tests org function GetVDCByName with the vdc specified
Expand Down Expand Up @@ -132,7 +133,7 @@ func (vcd *TestVCD) Test_CreateOrgVdcWithFlex(check *C) {
check.Assert(vdc, NotNil)
check.Assert(err, IsNil)

AddToCleanupList(vdcConfiguration.Name, "vdc", vcd.org.Org.Name, "Test_CreateVdcWithFlex")
AddToCleanupList(vdcConfiguration.Name, "vdc", vcd.org.Org.Name, "Test_CreateVdcWithFlex", "")

vdc, err = adminOrg.GetVDCByName(vdcConfiguration.Name, true)
check.Assert(err, IsNil)
Expand Down
74 changes: 63 additions & 11 deletions govcd/api_vcd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,11 @@ type TestVCD struct {
// Cleanup entity structure used by the tear-down procedure
// at the end of the tests to remove leftover entities
type CleanupEntity struct {
Name string
EntityType string
Parent string
CreatedBy string
Name string
EntityType string
Parent string
CreatedBy string
OpenApiEndpoint string
}

// CleanupInfo is the data used to persist an entity list in a file
Expand Down Expand Up @@ -334,36 +335,40 @@ func writeCleanupList(cleanupList []CleanupEntity) error {
return file.Close()
}

// Adds an entity to the cleanup list.
// AddToCleanupList adds an entity to the cleanup list.
// To be called by all tests when a new entity has been created, before
// running any other operation.
// Items in the list will be deleted at the end of the tests if they still exist.
func AddToCleanupList(name, entityType, parent, createdBy string) {
// For OpenApi objects `entityType=OpenApiEntity` and `openApiEndpoint`should be set in format
// "types.OpenApiPathVersion1_0_0 + types.OpenApiEndpointOrgVdcNetworks + ID"
func AddToCleanupList(name, entityType, parent, createdBy, openApiEndpoint string) {
for _, item := range cleanupEntityList {
// avoid adding the same item twice
if item.Name == name && item.EntityType == entityType {
return
}
}
cleanupEntityList = append(cleanupEntityList, CleanupEntity{Name: name, EntityType: entityType, Parent: parent, CreatedBy: createdBy})
cleanupEntityList = append(cleanupEntityList, CleanupEntity{Name: name, EntityType: entityType, Parent: parent, CreatedBy: createdBy, OpenApiEndpoint: openApiEndpoint})
err := writeCleanupList(cleanupEntityList)
if err != nil {
fmt.Printf("################ error writing cleanup list %s\n", err)
}
}

// Prepend an entity to the cleanup list.
// PrependToCleanupList prepends an entity to the cleanup list.
// To be called by all tests when a new entity has been created, before
// running any other operation.
// Items in the list will be deleted at the end of the tests if they still exist.
func PrependToCleanupList(name, entityType, parent, createdBy string) {
// For OpenApi objects `entityType=OpenApiEntity` and `openApiEndpoint`should be set in format
// "types.OpenApiPathVersion1_0_0 + types.OpenApiEndpointOrgVdcNetworks + ID"
func PrependToCleanupList(name, entityType, parent, createdBy, openApiEndpoint string) {
for _, item := range cleanupEntityList {
// avoid adding the same item twice
if item.Name == name && item.EntityType == entityType {
return
}
}
cleanupEntityList = append([]CleanupEntity{{Name: name, EntityType: entityType, Parent: parent, CreatedBy: createdBy}}, cleanupEntityList...)
cleanupEntityList = append([]CleanupEntity{{Name: name, EntityType: entityType, Parent: parent, CreatedBy: createdBy, OpenApiEndpoint: openApiEndpoint}}, cleanupEntityList...)
err := writeCleanupList(cleanupEntityList)
if err != nil {
fmt.Printf("################ error writing cleanup list %s\n", err)
Expand Down Expand Up @@ -695,6 +700,53 @@ func (vcd *TestVCD) removeLeftoverEntities(entity CleanupEntity) {
// For this reason, the [ERROR] messages won't be followed by a program termination
vcd.infoCleanup(introMsg, entity.EntityType, entity.Name, entity.CreatedBy)
switch entity.EntityType {

// openApiEntity can be used to delete any OpenAPI entity due to the API being uniform and allowing the same
// low level OpenApiDeleteItem()
case "OpenApiEntity":

// entity.OpenApiEndpoint contains "endpoint/{ID}"
// (in format types.OpenApiPathVersion1_0_0 + types.OpenApiEndpointOrgVdcNetworks + ID) but
// to lookup used API version this ID must not be present therefore below we remove suffix ID.
// This is done by splitting whole path by "/" and rebuilding path again without last element in slice (which is
// expected to be the ID)
endpointSlice := strings.Split(entity.OpenApiEndpoint, "/")
endpoint := strings.Join(endpointSlice[:len(endpointSlice)-1], "/") + "/"
apiVersion, _ := vcd.client.Client.checkOpenApiEndpointCompatibility(endpoint)

// Build UP complete endpoint address
urlRef, err := vcd.client.Client.OpenApiBuildEndpoint(entity.OpenApiEndpoint)
if err != nil {
vcd.infoCleanup(notDeletedMsg, entity.EntityType, entity.Name, err)
return
}

// Validate if the resource still exists
err = vcd.client.Client.OpenApiGetItem(apiVersion, urlRef, nil, nil)
if ContainsNotFound(err) {
vcd.infoCleanup(notFoundMsg, entity.EntityType, entity.Name)
return
}

if err != nil {
vcd.infoCleanup(notDeletedMsg, entity.EntityType, entity.Name, err)
return
}

if err != nil {
vcd.infoCleanup(notDeletedMsg, entity.EntityType, entity.Name, err)
return
}

// Attempt to use supplied path in entity.Parent for element deletion
err = vcd.client.Client.OpenApiDeleteItem(apiVersion, urlRef, nil)
if err != nil {
vcd.infoCleanup(notDeletedMsg, entity.EntityType, entity.Name, err)
return
}

vcd.infoCleanup(removedMsg, entity.EntityType, entity.Name, entity.CreatedBy)

case "vapp":
vapp, err := vcd.vdc.GetVAppByName(entity.Name, true)
if err != nil {
Expand Down Expand Up @@ -1486,7 +1538,7 @@ func (vcd *TestVCD) createTestVapp(name string) (*VApp, error) {
}
// After a successful creation, the entity is added to the cleanup list.
// If something fails after this point, the entity will be removed
AddToCleanupList(name, "vapp", "", "createTestVapp")
AddToCleanupList(name, "vapp", "", "createTestVapp", "")
err = task.WaitTaskCompletion()
if err != nil {
return nil, fmt.Errorf("error composing vapp: %s", err)
Expand Down
24 changes: 12 additions & 12 deletions govcd/catalog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func (vcd *TestVCD) Test_UpdateCatalog(check *C) {
check.Assert(err, IsNil)
// After a successful creation, the entity is added to the cleanup list.
// If something fails after this point, the entity will be removed
AddToCleanupList(TestUpdateCatalog, "catalog", vcd.config.VCD.Org, "Test_UpdateCatalog")
AddToCleanupList(TestUpdateCatalog, "catalog", vcd.config.VCD.Org, "Test_UpdateCatalog", "")
check.Assert(adminCatalog.AdminCatalog.Name, Equals, TestUpdateCatalog)

adminCatalog.AdminCatalog.Description = TestCreateCatalogDesc
Expand Down Expand Up @@ -129,7 +129,7 @@ func (vcd *TestVCD) Test_DeleteCatalog(check *C) {
check.Assert(err, IsNil)
// After a successful creation, the entity is added to the cleanup list.
// If something fails after this point, the entity will be removed
AddToCleanupList(TestDeleteCatalog, "catalog", vcd.config.VCD.Org, "Test_DeleteCatalog")
AddToCleanupList(TestDeleteCatalog, "catalog", vcd.config.VCD.Org, "Test_DeleteCatalog", "")
check.Assert(adminCatalog.AdminCatalog.Name, Equals, TestDeleteCatalog)
err = adminCatalog.Delete(true, true)
check.Assert(err, IsNil)
Expand Down Expand Up @@ -190,7 +190,7 @@ func (vcd *TestVCD) Test_UploadOvf_progress_works(check *C) {
err = uploadTask.WaitTaskCompletion()
check.Assert(err, IsNil)

AddToCleanupList(itemName, "catalogItem", vcd.org.Org.Name+"|"+vcd.config.VCD.Catalog.Name, "Test_UploadOvf")
AddToCleanupList(itemName, "catalogItem", vcd.org.Org.Name+"|"+vcd.config.VCD.Catalog.Name, "Test_UploadOvf", "")

catalog, err = org.GetCatalogByName(vcd.config.VCD.Catalog.Name, true)
check.Assert(err, IsNil)
Expand Down Expand Up @@ -225,7 +225,7 @@ func (vcd *TestVCD) Test_UploadOvf_ShowUploadProgress_works(check *C) {

err = uploadTask.WaitTaskCompletion()
check.Assert(err, IsNil)
AddToCleanupList(itemName, "catalogItem", vcd.org.Org.Name+"|"+vcd.config.VCD.Catalog.Name, "Test_UploadOvf")
AddToCleanupList(itemName, "catalogItem", vcd.org.Org.Name+"|"+vcd.config.VCD.Catalog.Name, "Test_UploadOvf", "")

check.Assert(string(result), Matches, "(?s).*Upload progress 100.00%.*")

Expand All @@ -252,7 +252,7 @@ func (vcd *TestVCD) Test_UploadOvf_error_withSameItem(check *C) {
err2 = uploadTask.WaitTaskCompletion()
check.Assert(err2, IsNil)

AddToCleanupList(itemName, "catalogItem", vcd.org.Org.Name+"|"+vcd.config.VCD.Catalog.Name, "Test_UploadOvf")
AddToCleanupList(itemName, "catalogItem", vcd.org.Org.Name+"|"+vcd.config.VCD.Catalog.Name, "Test_UploadOvf", "")

catalog, _ = findCatalog(vcd, check, vcd.config.VCD.Catalog.Name)
_, err3 := catalog.UploadOvf(vcd.config.OVA.OvaPath, itemName, "upload from test", 1024)
Expand All @@ -278,7 +278,7 @@ func (vcd *TestVCD) Test_UploadOvf_cleaned_extracted_files(check *C) {
err = uploadTask.WaitTaskCompletion()
check.Assert(err, IsNil)

AddToCleanupList(itemName, "catalogItem", vcd.org.Org.Name+"|"+vcd.config.VCD.Catalog.Name, "Test_UploadOvf")
AddToCleanupList(itemName, "catalogItem", vcd.org.Org.Name+"|"+vcd.config.VCD.Catalog.Name, "Test_UploadOvf", "")

check.Assert(oldFolderCount, Equals, countFolders())

Expand Down Expand Up @@ -324,7 +324,7 @@ func checkUploadOvf(vcd *TestVCD, check *C, ovaFileName, catalogName, itemName s
err = uploadTask.WaitTaskCompletion()
check.Assert(err, IsNil)

AddToCleanupList(itemName, "catalogItem", vcd.org.Org.Name+"|"+vcd.config.VCD.Catalog.Name, "Test_UploadOvf")
AddToCleanupList(itemName, "catalogItem", vcd.org.Org.Name+"|"+vcd.config.VCD.Catalog.Name, "Test_UploadOvf", "")

catalog, err = org.GetCatalogByName(catalogName, false)
check.Assert(err, IsNil)
Expand Down Expand Up @@ -377,7 +377,7 @@ func (vcd *TestVCD) Test_CatalogUploadMediaImage(check *C) {
err = uploadTask.WaitTaskCompletion()
check.Assert(err, IsNil)

AddToCleanupList(TestCatalogUploadMedia, "mediaCatalogImage", vcd.org.Org.Name+"|"+vcd.config.VCD.Catalog.Name, "Test_CatalogUploadMediaImage")
AddToCleanupList(TestCatalogUploadMedia, "mediaCatalogImage", vcd.org.Org.Name+"|"+vcd.config.VCD.Catalog.Name, "Test_CatalogUploadMediaImage", "")

//verifyMediaImageUploaded(vcd.vdc.client, check, TestUploadMedia)
catalog, err = org.GetCatalogByName(vcd.config.VCD.Catalog.Name, false)
Expand Down Expand Up @@ -407,7 +407,7 @@ func (vcd *TestVCD) Test_CatalogUploadMediaImage_progress_works(check *C) {
err = uploadTask.WaitTaskCompletion()
check.Assert(err, IsNil)

AddToCleanupList(itemName, "mediaCatalogImage", vcd.org.Org.Name+"|"+vcd.config.VCD.Catalog.Name, "Test_CatalogUploadMediaImage_progress_works")
AddToCleanupList(itemName, "mediaCatalogImage", vcd.org.Org.Name+"|"+vcd.config.VCD.Catalog.Name, "Test_CatalogUploadMediaImage_progress_works", "")

catalog, err = org.GetCatalogByName(vcd.config.VCD.Catalog.Name, false)
check.Assert(err, IsNil)
Expand Down Expand Up @@ -442,7 +442,7 @@ func (vcd *TestVCD) Test_CatalogUploadMediaImage_ShowUploadProgress_works(check
err = uploadTask.WaitTaskCompletion()
check.Assert(err, IsNil)

AddToCleanupList(itemName, "mediaCatalogImage", vcd.org.Org.Name+"|"+vcd.config.VCD.Catalog.Name, "Test_CatalogUploadMediaImage_ShowUploadProgress_works")
AddToCleanupList(itemName, "mediaCatalogImage", vcd.org.Org.Name+"|"+vcd.config.VCD.Catalog.Name, "Test_CatalogUploadMediaImage_ShowUploadProgress_works", "")

check.Assert(string(result), Matches, "(?s).*Upload progress 100.00%.*")
catalog, err = org.GetCatalogByName(vcd.config.VCD.Catalog.Name, false)
Expand All @@ -466,7 +466,7 @@ func (vcd *TestVCD) Test_CatalogUploadMediaImage_error_withSameItem(check *C) {
err = uploadTask.WaitTaskCompletion()
check.Assert(err, IsNil)

AddToCleanupList(itemName, "mediaCatalogImage", vcd.org.Org.Name+"|"+vcd.config.VCD.Catalog.Name, "Test_CatalogUploadMediaImage_error_withSameItem")
AddToCleanupList(itemName, "mediaCatalogImage", vcd.org.Org.Name+"|"+vcd.config.VCD.Catalog.Name, "Test_CatalogUploadMediaImage_error_withSameItem", "")
}

// Tests System function Delete by creating media item and
Expand All @@ -484,7 +484,7 @@ func (vcd *TestVCD) Test_CatalogDeleteMediaRecord(check *C) {
err = uploadTask.WaitTaskCompletion()
check.Assert(err, IsNil)

AddToCleanupList(itemName, "mediaCatalogImage", vcd.org.Org.Name+"|"+vcd.config.VCD.Catalog.Name, "Test_CatalogDeleteMediaImage")
AddToCleanupList(itemName, "mediaCatalogImage", vcd.org.Org.Name+"|"+vcd.config.VCD.Catalog.Name, "Test_CatalogDeleteMediaImage", "")

mediaRecord, err := catalog.QueryMedia(itemName)
check.Assert(err, IsNil)
Expand Down
2 changes: 1 addition & 1 deletion govcd/catalogitem_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (vcd *TestVCD) Test_GetVAppTemplate(check *C) {
// deleting it after.
func (vcd *TestVCD) Test_Delete(check *C) {
skipWhenOvaPathMissing(vcd.config.OVA.OvaPath, check)
AddToCleanupList(TestDeleteCatalogItem, "catalogItem", vcd.org.Org.Name+"|"+vcd.config.VCD.Catalog.Name, "Test_Delete")
AddToCleanupList(TestDeleteCatalogItem, "catalogItem", vcd.org.Org.Name+"|"+vcd.config.VCD.Catalog.Name, "Test_Delete", "")

// Fetching organization
org, err := vcd.client.GetAdminOrgByName(vcd.org.Org.Name)
Expand Down
Loading