-
Notifications
You must be signed in to change notification settings - Fork 63
Expand file tree
/
Copy pathdata_source_cloudstack_vpc_offering_test.go
More file actions
123 lines (112 loc) · 4.24 KB
/
Copy pathdata_source_cloudstack_vpc_offering_test.go
File metadata and controls
123 lines (112 loc) · 4.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
//
package cloudstack
import (
"testing"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
)
func TestAccVPCOfferingDataSource_basic(t *testing.T) {
resourceName := "cloudstack_vpc_offering.vpc-off-resource"
datasourceName := "data.cloudstack_vpc_offering.vpc-off-data-source"
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testVPCOfferingDataSourceConfig_basic,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrPair(datasourceName, "name", resourceName, "name"),
resource.TestCheckResourceAttrPair(datasourceName, "display_text", resourceName, "display_text"),
resource.TestCheckResourceAttrPair(datasourceName, "enable", resourceName, "enable"),
),
},
},
})
}
func TestAccVPCOfferingDataSource_withServices(t *testing.T) {
resourceName := "cloudstack_vpc_offering.vpc-off-resource"
datasourceName := "data.cloudstack_vpc_offering.vpc-off-data-source"
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testVPCOfferingDataSourceConfig_withServices,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrPair(datasourceName, "name", resourceName, "name"),
resource.TestCheckResourceAttrPair(datasourceName, "supported_services.#", resourceName, "supported_services.#"),
resource.TestCheckResourceAttrPair(datasourceName, "service_provider_list.%", resourceName, "service_provider_list.%"),
resource.TestCheckResourceAttrPair(datasourceName, "service_provider_list.Dhcp", resourceName, "service_provider_list.Dhcp"),
resource.TestCheckResourceAttrPair(datasourceName, "enable", resourceName, "enable"),
),
},
},
})
}
const testVPCOfferingDataSourceConfig_basic = `
resource "cloudstack_vpc_offering" "vpc-off-resource"{
name = "TestVPCOfferingDisplay01"
display_text = "TestVPCOfferingDisplay01"
enable = true
// CloudStack always injects SourceNat and NetworkACL support into a VPC
// offering even if omitted here, so they must be declared explicitly to
// avoid permanent post-apply drift on these ForceNew attributes.
supported_services = ["SourceNat", "NetworkACL"]
service_provider_list = {
SourceNat = "VpcVirtualRouter"
NetworkACL = "VpcVirtualRouter"
}
}
data "cloudstack_vpc_offering" "vpc-off-data-source"{
filter{
name = "name"
value = "TestVPCOfferingDisplay01"
}
depends_on = [
cloudstack_vpc_offering.vpc-off-resource
]
}
`
const testVPCOfferingDataSourceConfig_withServices = `
resource "cloudstack_vpc_offering" "vpc-off-resource"{
name = "TestVPCOfferingServices01"
display_text = "TestVPCOfferingServices01"
enable = true
supported_services = ["Dhcp", "Dns", "SourceNat", "PortForwarding", "Lb", "UserData", "StaticNat", "NetworkACL"]
service_provider_list = {
Dhcp = "VpcVirtualRouter"
Dns = "VpcVirtualRouter"
SourceNat = "VpcVirtualRouter"
PortForwarding = "VpcVirtualRouter"
Lb = "VpcVirtualRouter"
UserData = "VpcVirtualRouter"
StaticNat = "VpcVirtualRouter"
NetworkACL = "VpcVirtualRouter"
}
}
data "cloudstack_vpc_offering" "vpc-off-data-source"{
filter{
name = "name"
value = "TestVPCOfferingServices01"
}
depends_on = [
cloudstack_vpc_offering.vpc-off-resource
]
}
`