Skip to content

Commit 179ad43

Browse files
authored
Merge pull request #138 from yanndegat/fixtestacc
Fixtestacc
2 parents 6efc47a + 9af96c1 commit 179ad43

3 files changed

+13
-17
lines changed

ovh/resource_ovh_cloud_network_private_test.go

+9-15
Original file line numberDiff line numberDiff line change
@@ -90,43 +90,37 @@ func testSweepCloudNetworkPrivate(region string) error {
9090
return fmt.Errorf("OVH_PUBLIC_CLOUD must be set")
9191
}
9292

93-
networkIds := []string{}
94-
err = client.Get(fmt.Sprintf("/cloud/project/%s/network/private", projectId), &networkIds)
93+
networks := []CloudNetworkPrivateResponse{}
94+
err = client.Get(fmt.Sprintf("/cloud/project/%s/network/private", projectId), &networks)
9595
if err != nil {
9696
return fmt.Errorf("error listing private networks for project %q:\n\t %q", projectId, err)
9797
}
9898

99-
for _, n := range networkIds {
100-
r := &CloudNetworkPrivateResponse{}
101-
err = client.Get(fmt.Sprintf("/cloud/project/%s/network/private/%s", projectId, n), r)
102-
if err != nil {
103-
return fmt.Errorf("error getting private network %q for project %q:\n\t %q", n, projectId, err)
104-
}
105-
106-
if !strings.HasPrefix(r.Name, test_prefix) {
99+
for _, n := range networks {
100+
if !strings.HasPrefix(n.Name, test_prefix) {
107101
continue
108102
}
109103

110-
log.Printf("[DEBUG] found dangling network & subnets for project: %s, id: %s", projectId, n)
104+
log.Printf("[DEBUG] found dangling network & subnets for project: %s, id: %s", projectId, n.Id)
111105
err = resource.Retry(5*time.Minute, func() *resource.RetryError {
112106
subnetIds := []string{}
113-
err = client.Get(fmt.Sprintf("/cloud/project/%s/network/private/%s/subnet", projectId, n), &subnetIds)
107+
err = client.Get(fmt.Sprintf("/cloud/project/%s/network/private/%s/subnet", projectId, n.Id), &subnetIds)
114108
if err != nil {
115109
return resource.RetryableError(fmt.Errorf("error listing private network subnets for project %q:\n\t %q", projectId, err))
116110
}
117111

118112
for _, s := range subnetIds {
119-
if err := client.Delete(fmt.Sprintf("/cloud/project/%s/network/private/%s/subnet/%s", projectId, n, s), nil); err != nil {
113+
if err := client.Delete(fmt.Sprintf("/cloud/project/%s/network/private/%s/subnet/%s", projectId, n.Id, s), nil); err != nil {
120114
return resource.RetryableError(err)
121115
}
122116
}
123117

124-
if err := client.Delete(fmt.Sprintf("/cloud/project/%s/network/private/%s", projectId, n), nil); err != nil {
118+
if err := client.Delete(fmt.Sprintf("/cloud/project/%s/network/private/%s", projectId, n.Id), nil); err != nil {
125119
return resource.RetryableError(err)
126120
}
127121

128122
// Successful cascade delete
129-
log.Printf("[DEBUG] successful cascade delete of network & subnets for project: %s, id: %s", projectId, n)
123+
log.Printf("[DEBUG] successful cascade delete of network & subnets for project: %s, id: %s", projectId, n.Id)
130124
return nil
131125
})
132126

ovh/resource_ovh_domain_zone_record_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ func testSweepDomainZoneRecord(region string) error {
2929

3030
zoneName := os.Getenv("OVH_ZONE")
3131
if zoneName == "" {
32-
return fmt.Errorf("OVH_ZONE must be set")
32+
log.Print("[DEBUG] OVH_ZONE is not set. No zone to sweep")
33+
return nil
3334
}
3435

3536
dz := &DomainZone{}

ovh/resource_ovh_domain_zone_redirection_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ func testSweepDomainZoneRedirection(region string) error {
2929

3030
zoneName := os.Getenv("OVH_ZONE")
3131
if zoneName == "" {
32-
return fmt.Errorf("OVH_ZONE must be set")
32+
log.Print("[DEBUG] OVH_ZONE is not set. No zone to sweep")
33+
return nil
3334
}
3435

3536
dz := &DomainZone{}

0 commit comments

Comments
 (0)