forked from oracle/terraform-provider-oci
-
Notifications
You must be signed in to change notification settings - Fork 0
/
data_source_obmcs_load_balancer_certificates_test.go
57 lines (51 loc) · 1.65 KB
/
data_source_obmcs_load_balancer_certificates_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
// 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 TestLoadBalancerCertificatesDatasource(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_certificates.t"
config := `
data "baremetal_load_balancer_certificates" "t" {
load_balancer_id = "ocid1.loadbalancer.stub_id"
}
`
config += testProviderConfig()
loadbalancerID := "ocid1.loadbalancer.stub_id"
list := &baremetal.ListCertificates{
Certificates: []baremetal.Certificate{
{CertificateName: "stub_name1"},
{CertificateName: "stub_name2"},
},
}
client.On(
"ListCertificates",
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, "certificates.#", "2"),
resource.TestCheckResourceAttr(resourceName, "certificates.0.certificate_name", "stub_name1"),
resource.TestCheckResourceAttr(resourceName, "certificates.1.certificate_name", "stub_name2"),
),
},
},
})
}