forked from oracle/terraform-provider-oci
-
Notifications
You must be signed in to change notification settings - Fork 0
/
load_balancer_backendsets_datasource_test.go
59 lines (52 loc) · 1.66 KB
/
load_balancer_backendsets_datasource_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"
"github.com/oracle/terraform-provider-baremetal/client/mocks"
)
func TestLoadBalancerBackendsetsDatasource(t *testing.T) {
client := &mocks.BareMetalClient{}
providers := map[string]terraform.ResourceProvider{
"baremetal": Provider(func(d *schema.ResourceData) (interface{}, error) {
return client, nil
}),
}
resourceName := "data.baremetal_load_balancer_backendsets.t"
config := `
data "baremetal_load_balancer_backendsets" "t" {
load_balancer_id = "ocid1.loadbalancer.stub_id"
}
`
config += testProviderConfig
loadbalancerID := "ocid1.loadbalancer.stub_id"
list := &baremetal.ListBackendSets{
BackendSets: []baremetal.BackendSet{
{Name: "stub_name1"},
{Name: "stub_name2"},
},
}
client.On(
"ListBackendSets",
loadbalancerID,
(*baremetal.ClientRequestOptions)(nil),
).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, "backendsets.#", "2"),
resource.TestCheckResourceAttr(resourceName, "backendsets.0.name", "stub_name1"),
resource.TestCheckResourceAttr(resourceName, "backendsets.1.name", "stub_name2"),
),
},
},
})
}