forked from oracle/terraform-provider-oci
-
Notifications
You must be signed in to change notification settings - Fork 0
/
data_source_obmcs_load_balancer_backends_test.go
59 lines (53 loc) · 1.65 KB
/
data_source_obmcs_load_balancer_backends_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
// Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
package main
import (
"testing"
"github.com/MustWin/baremetal-sdk-go"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/terraform"
)
func TestLoadBalancerBackendsDatasource(t *testing.T) {
client := GetTestProvider()
providers := map[string]terraform.ResourceProvider{
"baremetal": Provider(func(d *schema.ResourceData) (interface{}, error) {
return client, nil
}),
}
resourceName := "data.baremetal_load_balancer_backends.t"
config := `
data "baremetal_load_balancer_backends" "t" {
load_balancer_id = "ocid1.loadbalancer.stub_id"
backendset_name = "stub_backendset_name"
}
`
config += testProviderConfig()
loadbalancerID := "ocid1.loadbalancer.stub_id"
backendsetName := "stub_backendset_name"
list := &baremetal.ListBackends{
Backends: []baremetal.Backend{
{IPAddress: "123.123.123.123"},
{IPAddress: "122.122.122.122"},
},
}
client.On(
"ListBackends",
loadbalancerID,
backendsetName,
).Return(list, nil)
resource.UnitTest(t, resource.TestCase{
PreventPostDestroyRefresh: true,
Providers: providers,
Steps: []resource.TestStep{
{
Config: config,
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr(resourceName, "load_balancer_id", loadbalancerID),
resource.TestCheckResourceAttr(resourceName, "backends.#", "2"),
resource.TestCheckResourceAttr(resourceName, "backends.0.name", "123.123.123.123"),
resource.TestCheckResourceAttr(resourceName, "backends.1.name", "122.122.122.122"),
),
},
},
})
}