Skip to content

Commit 2585195

Browse files
committed
test fixes for datasource only cases
1 parent f7a17bd commit 2585195

7 files changed

+17
-400
lines changed

provider/core_instance_credential_test.go

Lines changed: 2 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ import (
1212

1313
const (
1414
InstanceCredentialResourceConfig = InstanceCredentialResourceDependencies + `
15-
resource "oci_core_instance_credential" "test_instance_credential" {
16-
}
15+
1716
`
1817
InstanceCredentialPropertyVariables = `
1918
variable "instance_credential_instance_id" { default = "instanceId" }
@@ -23,59 +22,19 @@ variable "instance_credential_instance_id" { default = "instanceId" }
2322
)
2423

2524
func TestCoreInstanceCredentialResource_basic(t *testing.T) {
26-
t.Skip("InstanceCredentials is a data source only artifact. Data source test is covered by legacy test. Need to enable data source only tests in generator. https://jira.aka.lgl.grungy.us/browse/ORCH-708")
27-
2825
provider := testAccProvider
2926
config := testProviderConfig()
3027

31-
compartmentId := getRequiredEnvSetting("compartment_id_for_create")
32-
compartmentIdVariableStr := fmt.Sprintf("variable \"compartment_id\" { default = \"%s\" }\n", compartmentId)
3328
compartmentId2 := getRequiredEnvSetting("compartment_id_for_update")
3429
compartmentIdVariableStr2 := fmt.Sprintf("variable \"compartment_id\" { default = \"%s\" }\n", compartmentId2)
3530

36-
resourceName := "oci_core_instance_credential.test_instance_credential"
3731
datasourceName := "data.oci_core_instance_credentials.test_instance_credentials"
3832

39-
var resId, resId2 string
40-
4133
resource.Test(t, resource.TestCase{
4234
Providers: map[string]terraform.ResourceProvider{
4335
"oci": provider,
4436
},
4537
Steps: []resource.TestStep{
46-
// verify create
47-
{
48-
ImportState: true,
49-
ImportStateVerify: true,
50-
Config: config + InstanceCredentialPropertyVariables + compartmentIdVariableStr + InstanceCredentialResourceConfig,
51-
Check: resource.ComposeAggregateTestCheckFunc(
52-
53-
func(s *terraform.State) (err error) {
54-
resId, err = fromInstanceState(s, resourceName, "id")
55-
return err
56-
},
57-
),
58-
},
59-
60-
// verify updates to Force New parameters.
61-
{
62-
Config: config + `
63-
variable "instance_credential_instance_id" { default = "instanceId2" }
64-
65-
` + compartmentIdVariableStr2 + InstanceCredentialResourceConfig,
66-
Check: resource.ComposeAggregateTestCheckFunc(
67-
resource.TestCheckResourceAttrSet(resourceName, "password"),
68-
resource.TestCheckResourceAttrSet(resourceName, "username"),
69-
70-
func(s *terraform.State) (err error) {
71-
resId2, err = fromInstanceState(s, resourceName, "id")
72-
if resId == resId2 {
73-
return fmt.Errorf("Resource was expected to be recreated but it wasn't.")
74-
}
75-
return err
76-
},
77-
),
78-
},
7938
// verify datasource
8039
{
8140
Config: config + `
@@ -84,17 +43,12 @@ variable "instance_credential_instance_id" { default = "instanceId2" }
8443
data "oci_core_instance_credentials" "test_instance_credentials" {
8544
#Required
8645
instance_id = "${var.instance_credential_instance_id}"
87-
88-
filter {
89-
name = "id"
90-
values = ["${oci_core_instance_credential.test_instance_credential.id}"]
91-
}
9246
}
9347
` + compartmentIdVariableStr2 + InstanceCredentialResourceConfig,
9448
Check: resource.ComposeTestCheckFunc(
9549
resource.TestCheckResourceAttr(datasourceName, "instance_id", "instanceId2"),
9650

97-
resource.TestCheckResourceAttr(datasourceName, "instance_credentials.#", "1"),
51+
resource.TestCheckResourceAttrSet(datasourceName, "instance_credentials.#"),
9852
resource.TestCheckResourceAttrSet(datasourceName, "instance_credentials.0.password"),
9953
resource.TestCheckResourceAttrSet(datasourceName, "instance_credentials.0.username"),
10054
),

provider/core_shape_test.go

Lines changed: 6 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ import (
1212

1313
const (
1414
ShapeResourceConfig = ShapeResourceDependencies + `
15-
resource "oci_core_shape" "test_shape" {
16-
}
15+
1716
`
1817
ShapePropertyVariables = `
1918
variable "shape_availability_domain" { default = "availabilityDomain" }
@@ -24,58 +23,19 @@ variable "shape_image_id" { default = "imageId" }
2423
)
2524

2625
func TestCoreShapeResource_basic(t *testing.T) {
27-
t.Skip("Creating shape resource is not supported. Data source test is covered by legacy test. Need to enable data source only tests in generator. https://jira.aka.lgl.grungy.us/browse/ORCH-708")
2826
provider := testAccProvider
2927
config := testProviderConfig()
3028

31-
compartmentId := getRequiredEnvSetting("compartment_id_for_create")
32-
compartmentIdVariableStr := fmt.Sprintf("variable \"compartment_id\" { default = \"%s\" }\n", compartmentId)
3329
compartmentId2 := getRequiredEnvSetting("compartment_id_for_update")
3430
compartmentIdVariableStr2 := fmt.Sprintf("variable \"compartment_id\" { default = \"%s\" }\n", compartmentId2)
3531

36-
resourceName := "oci_core_shape.test_shape"
3732
datasourceName := "data.oci_core_shapes.test_shapes"
3833

39-
var resId, resId2 string
40-
4134
resource.Test(t, resource.TestCase{
4235
Providers: map[string]terraform.ResourceProvider{
4336
"oci": provider,
4437
},
4538
Steps: []resource.TestStep{
46-
// verify create
47-
{
48-
ImportState: true,
49-
ImportStateVerify: true,
50-
Config: config + ShapePropertyVariables + compartmentIdVariableStr + ShapeResourceConfig,
51-
Check: resource.ComposeAggregateTestCheckFunc(
52-
53-
func(s *terraform.State) (err error) {
54-
resId, err = fromInstanceState(s, resourceName, "id")
55-
return err
56-
},
57-
),
58-
},
59-
60-
// verify updates to Force New parameters.
61-
{
62-
Config: config + `
63-
variable "shape_availability_domain" { default = "availabilityDomain2" }
64-
variable "shape_image_id" { default = "imageId2" }
65-
66-
` + compartmentIdVariableStr2 + ShapeResourceConfig,
67-
Check: resource.ComposeAggregateTestCheckFunc(
68-
resource.TestCheckResourceAttrSet(resourceName, "name"),
69-
70-
func(s *terraform.State) (err error) {
71-
resId2, err = fromInstanceState(s, resourceName, "id")
72-
if resId == resId2 {
73-
return fmt.Errorf("Resource was expected to be recreated but it wasn't.")
74-
}
75-
return err
76-
},
77-
),
78-
},
7939
// verify datasource
8040
{
8141
Config: config + `
@@ -87,21 +47,16 @@ data "oci_core_shapes" "test_shapes" {
8747
compartment_id = "${var.compartment_id}"
8848
8949
#Optional
90-
availability_domain = "${var.shape_availability_domain}"
91-
image_id = "${var.shape_image_id}"
92-
93-
filter {
94-
name = "id"
95-
values = ["${oci_core_shape.test_shape.id}"]
96-
}
50+
#availability_domain = "${var.shape_availability_domain}"
51+
#image_id = "${var.shape_image_id}"
9752
}
9853
` + compartmentIdVariableStr2 + ShapeResourceConfig,
9954
Check: resource.ComposeTestCheckFunc(
100-
resource.TestCheckResourceAttr(datasourceName, "availability_domain", "availabilityDomain2"),
55+
//resource.TestCheckResourceAttr(datasourceName, "availability_domain", "availabilityDomain2"),
10156
resource.TestCheckResourceAttr(datasourceName, "compartment_id", compartmentId2),
102-
resource.TestCheckResourceAttr(datasourceName, "image_id", "imageId2"),
57+
//resource.TestCheckResourceAttr(datasourceName, "image_id", "imageId2"),
10358

104-
resource.TestCheckResourceAttr(datasourceName, "shapes.#", "1"),
59+
resource.TestCheckResourceAttrSet(datasourceName, "shapes.#"),
10560
resource.TestCheckResourceAttrSet(datasourceName, "shapes.0.name"),
10661
),
10762
},

provider/identity_availability_domain_test.go

Lines changed: 3 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ import (
1212

1313
const (
1414
AvailabilityDomainResourceConfig = AvailabilityDomainResourceDependencies + `
15-
resource "oci_identity_availability_domain" "test_availability_domain" {
16-
}
15+
1716
`
1817
AvailabilityDomainPropertyVariables = `
1918
@@ -22,73 +21,33 @@ resource "oci_identity_availability_domain" "test_availability_domain" {
2221
)
2322

2423
func TestIdentityAvailabilityDomainResource_basic(t *testing.T) {
25-
t.Skip("Creating availability domain resource is not supported. Data source test is covered by legacy test. Need to enable data source only tests in generator. https://jira.aka.lgl.grungy.us/browse/ORCH-708")
2624
provider := testAccProvider
2725
config := testProviderConfig()
2826

29-
compartmentId := getRequiredEnvSetting("compartment_id_for_create")
30-
compartmentIdVariableStr := fmt.Sprintf("variable \"compartment_id\" { default = \"%s\" }\n", compartmentId)
3127
compartmentId2 := getRequiredEnvSetting("compartment_id_for_update")
3228
compartmentIdVariableStr2 := fmt.Sprintf("variable \"compartment_id\" { default = \"%s\" }\n", compartmentId2)
3329

34-
resourceName := "oci_identity_availability_domain.test_availability_domain"
3530
datasourceName := "data.oci_identity_availability_domains.test_availability_domains"
3631

37-
var resId, resId2 string
38-
3932
resource.Test(t, resource.TestCase{
4033
Providers: map[string]terraform.ResourceProvider{
4134
"oci": provider,
4235
},
4336
Steps: []resource.TestStep{
44-
// verify create
45-
{
46-
ImportState: true,
47-
ImportStateVerify: true,
48-
Config: config + AvailabilityDomainPropertyVariables + compartmentIdVariableStr + AvailabilityDomainResourceConfig,
49-
Check: resource.ComposeAggregateTestCheckFunc(
50-
51-
func(s *terraform.State) (err error) {
52-
resId, err = fromInstanceState(s, resourceName, "id")
53-
return err
54-
},
55-
),
56-
},
57-
58-
// verify updates to Force New parameters.
59-
{
60-
Config: config + `
61-
62-
` + compartmentIdVariableStr2 + AvailabilityDomainResourceConfig,
63-
Check: resource.ComposeAggregateTestCheckFunc(
64-
65-
func(s *terraform.State) (err error) {
66-
resId2, err = fromInstanceState(s, resourceName, "id")
67-
if resId == resId2 {
68-
return fmt.Errorf("Resource was expected to be recreated but it wasn't.")
69-
}
70-
return err
71-
},
72-
),
73-
},
7437
// verify datasource
7538
{
7639
Config: config + `
7740
7841
data "oci_identity_availability_domains" "test_availability_domains" {
7942
#Required
8043
compartment_id = "${var.compartment_id}"
81-
82-
filter {
83-
name = "id"
84-
values = ["${oci_identity_availability_domain.test_availability_domain.id}"]
85-
}
8644
}
8745
` + compartmentIdVariableStr2 + AvailabilityDomainResourceConfig,
8846
Check: resource.ComposeTestCheckFunc(
8947
resource.TestCheckResourceAttr(datasourceName, "compartment_id", compartmentId2),
9048

91-
resource.TestCheckResourceAttr(datasourceName, "availability_domains.#", "1"),
49+
resource.TestCheckResourceAttrSet(datasourceName, "availability_domains.#"),
50+
resource.TestCheckResourceAttrSet(datasourceName, "availability_domains.0.name"),
9251
),
9352
},
9453
},

provider/load_balancer_load_balancer_policy_test.go

Lines changed: 2 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ import (
1212

1313
const (
1414
LoadBalancerPolicyResourceConfig = LoadBalancerPolicyResourceDependencies + `
15-
resource "oci_load_balancer_load_balancer_policy" "test_load_balancer_policy" {
16-
}
15+
1716
`
1817
LoadBalancerPolicyPropertyVariables = `
1918
@@ -25,70 +24,29 @@ func TestLoadBalancerLoadBalancerPolicyResource_basic(t *testing.T) {
2524
provider := testAccProvider
2625
config := testProviderConfig()
2726

28-
compartmentId := getRequiredEnvSetting("compartment_id_for_create")
29-
compartmentIdVariableStr := fmt.Sprintf("variable \"compartment_id\" { default = \"%s\" }\n", compartmentId)
3027
compartmentId2 := getRequiredEnvSetting("compartment_id_for_update")
3128
compartmentIdVariableStr2 := fmt.Sprintf("variable \"compartment_id\" { default = \"%s\" }\n", compartmentId2)
3229

33-
resourceName := "oci_load_balancer_load_balancer_policy.test_load_balancer_policy"
3430
datasourceName := "data.oci_load_balancer_policies.test_load_balancer_policies"
3531

36-
var resId, resId2 string
37-
3832
resource.Test(t, resource.TestCase{
3933
Providers: map[string]terraform.ResourceProvider{
4034
"oci": provider,
4135
},
4236
Steps: []resource.TestStep{
43-
// verify create
44-
{
45-
ImportState: true,
46-
ImportStateVerify: true,
47-
Config: config + LoadBalancerPolicyPropertyVariables + compartmentIdVariableStr + LoadBalancerPolicyResourceConfig,
48-
Check: resource.ComposeAggregateTestCheckFunc(
49-
50-
func(s *terraform.State) (err error) {
51-
resId, err = fromInstanceState(s, resourceName, "id")
52-
return err
53-
},
54-
),
55-
},
56-
57-
// verify updates to Force New parameters.
58-
{
59-
Config: config + `
60-
61-
` + compartmentIdVariableStr2 + LoadBalancerPolicyResourceConfig,
62-
Check: resource.ComposeAggregateTestCheckFunc(
63-
resource.TestCheckResourceAttrSet(resourceName, "name"),
64-
65-
func(s *terraform.State) (err error) {
66-
resId2, err = fromInstanceState(s, resourceName, "id")
67-
if resId == resId2 {
68-
return fmt.Errorf("Resource was expected to be recreated but it wasn't.")
69-
}
70-
return err
71-
},
72-
),
73-
},
7437
// verify datasource
7538
{
7639
Config: config + `
7740
7841
data "oci_load_balancer_policies" "test_load_balancer_policies" {
7942
#Required
8043
compartment_id = "${var.compartment_id}"
81-
82-
filter {
83-
name = "id"
84-
values = ["${oci_load_balancer_load_balancer_policy.test_load_balancer_policy.id}"]
85-
}
8644
}
8745
` + compartmentIdVariableStr2 + LoadBalancerPolicyResourceConfig,
8846
Check: resource.ComposeTestCheckFunc(
8947
resource.TestCheckResourceAttr(datasourceName, "compartment_id", compartmentId2),
9048

91-
resource.TestCheckResourceAttr(datasourceName, "policies.#", "1"),
49+
resource.TestCheckResourceAttrSet(datasourceName, "policies.#"),
9250
resource.TestCheckResourceAttrSet(datasourceName, "policies.0.name"),
9351
),
9452
},

0 commit comments

Comments
 (0)