-
Notifications
You must be signed in to change notification settings - Fork 147
/
Copy pathdata_iploadbalancing_test.go
72 lines (65 loc) · 2.02 KB
/
data_iploadbalancing_test.go
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
package ovh
import (
"fmt"
"os"
"testing"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)
func TestAccIpLoadbalancingDataSource_basic(t *testing.T) {
serviceName := os.Getenv("OVH_IPLB_SERVICE_TEST")
config := fmt.Sprintf(testAccIpLoadbalancingDatasourceConfig_Basic, serviceName)
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheckIpLoadbalancing(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: config,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(
"data.ovh_iploadbalancing.iplb", "service_name", serviceName),
resource.TestCheckResourceAttr(
"data.ovh_iploadbalancing.iplb", "id", serviceName),
resource.TestCheckResourceAttrSet(
"data.ovh_iploadbalancing.iplb", "urn"),
),
},
},
})
}
func TestAccIpLoadbalancingDataSource_statevrack(t *testing.T) {
serviceName := os.Getenv("OVH_IPLB_SERVICE_TEST")
config := fmt.Sprintf(testAccIpLoadbalancingDatasourceConfig_StateAndVrack, serviceName)
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheckIpLoadbalancing(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: config,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(
"data.ovh_iploadbalancing.iplb", "service_name", serviceName),
resource.TestCheckResourceAttr(
"data.ovh_iploadbalancing.iplb", "id", serviceName),
resource.TestCheckResourceAttr(
"data.ovh_iploadbalancing.iplb", "state", "ok"),
resource.TestCheckResourceAttr(
"data.ovh_iploadbalancing.iplb", "vrack_eligibility", "true"),
resource.TestCheckResourceAttrSet(
"data.ovh_iploadbalancing.iplb", "urn"),
),
},
},
})
}
const testAccIpLoadbalancingDatasourceConfig_Basic = `
data "ovh_iploadbalancing" "iplb" {
service_name = "%s"
}
`
const testAccIpLoadbalancingDatasourceConfig_StateAndVrack = `
data "ovh_iploadbalancing" "iplb" {
service_name = "%s"
state = "ok"
vrack_eligibility = true
}
`