forked from oracle/terraform-provider-oci
-
Notifications
You must be signed in to change notification settings - Fork 0
/
load_balancer_policies_datasource_test.go
59 lines (52 loc) · 1.68 KB
/
load_balancer_policies_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 TestLoadBalancerPoliciesDatasource(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_policies.t"
config := `
data "baremetal_load_balancer_policies" "t" {
compartment_id = "ocid1.compartment.stub_id"
}
`
config += testProviderConfig
compartmentID := "ocid1.compartment.stub_id"
list := &baremetal.ListLoadBalancerPolicies{
LoadBalancerPolicies: []baremetal.LoadBalancerPolicy{
{Name: "stub_name1"},
{Name: "stub_name2"},
},
}
client.On(
"ListLoadBalancerPolicies",
compartmentID,
(*baremetal.ListLoadBalancerPolicyOptions)(nil),
).Return(list, nil)
resource.UnitTest(t, resource.TestCase{
PreventPostDestroyRefresh: true,
Providers: providers,
Steps: []resource.TestStep{
{
Config: config,
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr(resourceName, "compartment_id", compartmentID),
resource.TestCheckResourceAttr(resourceName, "policies.#", "2"),
resource.TestCheckResourceAttr(resourceName, "policies.0.name", "stub_name1"),
resource.TestCheckResourceAttr(resourceName, "policies.1.name", "stub_name2"),
),
},
},
})
}