Skip to content

Commit 00e81d2

Browse files
committed
fixes for test failures
1 parent ef48e65 commit 00e81d2

8 files changed

+36
-12
lines changed

provider/core_dhcp_options_resource.go

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import (
1010
"github.com/hashicorp/terraform/helper/schema"
1111
"github.com/hashicorp/terraform/helper/validation"
1212

13+
"fmt"
14+
1315
oci_core "github.com/oracle/oci-go-sdk/core"
1416
)
1517

@@ -212,7 +214,11 @@ func (s *DhcpOptionsResourceCrud) Create() error {
212214
interfaces := options.([]interface{})
213215
tmp := make([]oci_core.DhcpOption, len(interfaces))
214216
for i, toBeConverted := range interfaces {
215-
tmp[i] = mapToDhcpOption(toBeConverted.(map[string]interface{}))
217+
converted, err := mapToDhcpOption(toBeConverted.(map[string]interface{}))
218+
if err != nil {
219+
return err
220+
}
221+
tmp[i] = converted
216222
}
217223
request.Options = tmp
218224
}
@@ -278,7 +284,11 @@ func (s *DhcpOptionsResourceCrud) Update() error {
278284
interfaces := options.([]interface{})
279285
tmp := make([]oci_core.DhcpOption, len(interfaces))
280286
for i, toBeConverted := range interfaces {
281-
tmp[i] = mapToDhcpOption(toBeConverted.(map[string]interface{}))
287+
converted, err := mapToDhcpOption(toBeConverted.(map[string]interface{}))
288+
if err != nil {
289+
return err
290+
}
291+
tmp[i] = converted
282292
}
283293
request.Options = tmp
284294
}
@@ -340,7 +350,7 @@ func (s *DhcpOptionsResourceCrud) SetData() error {
340350
return nil
341351
}
342352

343-
func mapToDhcpOption(raw map[string]interface{}) oci_core.DhcpOption {
353+
func mapToDhcpOption(raw map[string]interface{}) (oci_core.DhcpOption, error) {
344354
var baseObject oci_core.DhcpOption
345355
//discriminator
346356
typeRaw, ok := raw["type"]
@@ -352,6 +362,9 @@ func mapToDhcpOption(raw map[string]interface{}) oci_core.DhcpOption {
352362
}
353363
switch strings.ToLower(type_) {
354364
case strings.ToLower("DomainNameServer"):
365+
if searchDomainNames, ok := raw["search_domain_names"]; ok && len(searchDomainNames.([]interface{})) > 0 {
366+
return nil, fmt.Errorf("'search_domain_names' should not be specified for type DomainNameServer")
367+
}
355368
details := oci_core.DhcpDnsOption{}
356369
details.CustomDnsServers = []string{}
357370
if customDnsServers, ok := raw["custom_dns_servers"]; ok {
@@ -367,6 +380,14 @@ func mapToDhcpOption(raw map[string]interface{}) oci_core.DhcpOption {
367380
}
368381
baseObject = details
369382
case strings.ToLower("SearchDomain"):
383+
if customDnsServers, ok := raw["custom_dns_servers"]; ok && len(customDnsServers.([]interface{})) > 0 {
384+
return nil, fmt.Errorf("'custom_dns_servers' should not be specified for type SearchDomain")
385+
}
386+
387+
if serverType, ok := raw["server_type"]; ok && len(serverType.(string)) > 0 {
388+
return nil, fmt.Errorf("'server_type' should not be specified for type SearchDomain")
389+
}
390+
370391
details := oci_core.DhcpSearchDomainOption{}
371392
details.SearchDomainNames = []string{}
372393
if searchDomainNames, ok := raw["search_domain_names"]; ok {
@@ -380,8 +401,9 @@ func mapToDhcpOption(raw map[string]interface{}) oci_core.DhcpOption {
380401
baseObject = details
381402
default:
382403
log.Printf("[WARN] Unknown type '%v' was specified", type_)
404+
return baseObject, fmt.Errorf("unknown type '%v' was specified", type_)
383405
}
384-
return baseObject
406+
return baseObject, nil
385407
}
386408

387409
func DhcpOptionToMap(obj oci_core.DhcpOption) map[string]interface{} {

provider/database_db_home_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ variable "db_home_db_version" { default = "12.1.0.2" }
7878
)
7979

8080
func TestDatabaseDbHomeResource_basic(t *testing.T) {
81+
t.Skip("Skipping this test for now as dbhome is not supported as a resource for now.")
8182
provider := testAccProvider
8283
config := testProviderConfig()
8384

provider/helpers_objectstorage.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ import (
1212
"os"
1313
"sync"
1414

15+
"strings"
16+
1517
"github.com/oracle/oci-go-sdk/common"
1618
oci_object_storage "github.com/oracle/oci-go-sdk/objectstorage"
17-
"strings"
1819
)
1920

2021
const defaultFilePartSize int64 = 128 * 1024 * 1024 // 128MB

provider/identity_policy_resource_test.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,8 @@ func (s *ResourceIdentityPolicyTestSuite) TestAccResourceIdentityPolicy_basic()
6262
resource.TestCheckResourceAttrSet(s.ResourceName, "compartment_id"),
6363
resource.TestCheckResourceAttrSet(s.ResourceName, "time_created"),
6464
resource.TestCheckResourceAttrSet(s.ResourceName, "ETag"),
65-
resource.TestCheckResourceAttrSet(s.ResourceName, "etag"),
6665
resource.TestCheckResourceAttrSet(s.ResourceName, "lastUpdateETag"),
67-
resource.TestCheckResourceAttrSet(s.ResourceName, "last_update_etag"),
6866
resource.TestCheckResourceAttrSet(s.ResourceName, "policyHash"),
69-
resource.TestCheckResourceAttrSet(s.ResourceName, "policy_hash"),
7067
resource.TestCheckResourceAttr(s.ResourceName, "name", "p1-"+s.Token),
7168
resource.TestCheckResourceAttr(s.ResourceName, "description", "automated test policy"),
7269
resource.TestCheckResourceAttr(s.ResourceName, "statements.#", "1"),

provider/object_storage_object_head_data_source_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func (s *DatasourceObjectstorageObjectHeadTestSuite) SetupTest() {
4141
object = "-tf-object"
4242
content = "test content"
4343
metadata = {
44-
"content_type" = "text/plain"
44+
"content-type" = "text/plain"
4545
}
4646
}`, nil)
4747
s.ResourceName = "data.oci_objectstorage_object_head.t"

provider/object_storage_object_resource.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ import (
1818

1919
"strconv"
2020

21-
oci_object_storage "github.com/oracle/oci-go-sdk/objectstorage"
2221
"os"
22+
23+
oci_object_storage "github.com/oracle/oci-go-sdk/objectstorage"
2324
)
2425

2526
const (

provider/object_storage_object_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@ import (
1010
"regexp"
1111
"testing"
1212

13+
"os"
14+
"strconv"
15+
1316
"github.com/hashicorp/terraform/helper/resource"
1417
"github.com/hashicorp/terraform/terraform"
1518
"github.com/oracle/oci-go-sdk/common"
1619
oci_object_storage "github.com/oracle/oci-go-sdk/objectstorage"
17-
"os"
18-
"strconv"
1920
)
2021

2122
const (

provider/provider.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,7 @@ func resourcesMap() map[string]*schema.Resource {
324324
"oci_core_volume_attachment": VolumeAttachmentResource(),
325325
"oci_core_volume_backup": VolumeBackupResource(),
326326
"oci_core_volume_backup_policy_assignment": VolumeBackupPolicyAssignmentResource(),
327+
//Do remember to enable database_db_home_test if you are enabling DB Home resource
327328
//"oci_database_db_home": DbHomeResource(),
328329
"oci_database_db_system": DbSystemResource(),
329330
"oci_database_backup": BackupResource(),

0 commit comments

Comments
 (0)