Skip to content

Commit f82b146

Browse files
committed
Remove all the old mock code, not all TF tests are acceptance tests
1 parent ad81aca commit f82b146

File tree

81 files changed

+157
-3184
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+157
-3184
lines changed

data_source_obmcs_core_console_history_data_test.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ package main
55
import (
66
"testing"
77

8-
"github.com/MustWin/baremetal-sdk-go"
98
"github.com/hashicorp/terraform/helper/resource"
109
"github.com/hashicorp/terraform/helper/schema"
1110
"github.com/hashicorp/terraform/terraform"
@@ -52,19 +51,6 @@ func (s *CoreConsoleHistoryDataDatasourceTestSuite) TestResourceShowConsoleHisto
5251
data := make([]byte, 100)
5352
rand.Read(data)
5453

55-
opts := &baremetal.ConsoleHistoryDataOptions{}
56-
opts.Length = 1
57-
opts.Offset = 1
58-
59-
s.Client.On("ShowConsoleHistoryData", "ichid", opts).
60-
Return(
61-
&baremetal.ConsoleHistoryData{
62-
BytesRemaining: 50,
63-
Data: string(data),
64-
},
65-
nil,
66-
)
67-
6854
resource.UnitTest(s.T(), resource.TestCase{
6955
PreventPostDestroyRefresh: true,
7056
Providers: s.Providers,

data_source_obmcs_core_cpe_test.go

Lines changed: 1 addition & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -49,24 +49,6 @@ data "baremetal_core_cpes" "s" {
4949
}
5050

5151
func (s *DatasourceCoreCpeTestSuite) TestCpeList() {
52-
s.Client.On(
53-
"ListCpes",
54-
"compartmentid",
55-
&baremetal.ListOptions{},
56-
).Return(
57-
&baremetal.ListCpes{
58-
Cpes: []baremetal.Cpe{
59-
{
60-
ID: "id1",
61-
CompartmentID: "compartmentid",
62-
DisplayName: "name1",
63-
IPAddress: "142.10.10.2",
64-
TimeCreated: baremetal.Time{Time: time.Now()},
65-
},
66-
},
67-
},
68-
nil,
69-
)
7052

7153
resource.UnitTest(s.T(), resource.TestCase{
7254
PreventPostDestroyRefresh: true,
@@ -86,7 +68,6 @@ func (s *DatasourceCoreCpeTestSuite) TestCpeList() {
8668
},
8769
)
8870

89-
s.Client.AssertCalled(s.T(), "ListCpes", "compartmentid", &baremetal.ListOptions{})
9071
}
9172

9273
func (s *DatasourceCoreCpeTestSuite) TestCpePagedList() {
@@ -112,40 +93,6 @@ func (s *DatasourceCoreCpeTestSuite) TestCpePagedList() {
11293
},
11394
}
11495

115-
s.Client.On(
116-
"ListCpes",
117-
"compartmentid",
118-
&baremetal.ListOptions{},
119-
).Return(res, nil)
120-
121-
opts := &baremetal.ListOptions{}
122-
opts.Page = "nextpage"
123-
s.Client.On(
124-
"ListCpes",
125-
"compartmentid",
126-
opts,
127-
).Return(
128-
&baremetal.ListCpes{
129-
Cpes: []baremetal.Cpe{
130-
{
131-
ID: "id3",
132-
CompartmentID: "compartmentid",
133-
DisplayName: "name",
134-
IPAddress: "10.10.10.4",
135-
TimeCreated: baremetal.Time{Time: time.Now()},
136-
},
137-
{
138-
ID: "id4",
139-
CompartmentID: "compartmentid",
140-
DisplayName: "name",
141-
IPAddress: "10.10.10.5",
142-
TimeCreated: baremetal.Time{Time: time.Now()},
143-
},
144-
},
145-
},
146-
nil,
147-
)
148-
14996
resource.UnitTest(s.T(), resource.TestCase{
15097
PreventPostDestroyRefresh: true,
15198
Providers: s.Providers,
@@ -169,7 +116,7 @@ func (s *DatasourceCoreCpeTestSuite) TestCpePagedList() {
169116
},
170117
)
171118

172-
// s.Client.AssertCalled(s.T(), "ListCpes", "compartmentid", &baremetal.ListOptions{})
119+
//
173120
}
174121

175122
func TestDatasourceCoreCpeTestSuite(t *testing.T) {

data_source_obmcs_core_dhcp_options_test.go

Lines changed: 0 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,12 @@ package main
44

55
import (
66
"testing"
7-
"time"
87

98
"github.com/MustWin/baremetal-sdk-go"
109
"github.com/hashicorp/terraform/helper/resource"
1110
"github.com/hashicorp/terraform/helper/schema"
1211
"github.com/hashicorp/terraform/terraform"
1312

14-
15-
16-
1713
"github.com/stretchr/testify/suite"
1814
)
1915

@@ -46,37 +42,9 @@ func (s *ResourceCoreDHCPOptionsDatasourceTestSuite) SetupTest() {
4642
`
4743
s.Config += testProviderConfig()
4844
s.ResourceName = "data.baremetal_core_dhcp_options.t"
49-
50-
b1 := baremetal.DHCPOptions{
51-
CompartmentID: "compartment_id",
52-
DisplayName: "display_name",
53-
ID: "id1",
54-
Options: []baremetal.DHCPDNSOption{
55-
{
56-
Type: "type",
57-
CustomDNSServers: []string{"server_type"},
58-
ServerType: "server_type",
59-
},
60-
},
61-
State: baremetal.ResourceAvailable,
62-
TimeCreated: baremetal.Time{Time: time.Now()},
63-
}
64-
65-
b2 := b1
66-
b2.ID = "id2"
67-
68-
s.List = &baremetal.ListDHCPOptions{
69-
DHCPOptions: []baremetal.DHCPOptions{b1, b2},
70-
}
7145
}
7246

7347
func (s *ResourceCoreDHCPOptionsDatasourceTestSuite) TestReadDHCPOptions() {
74-
opts := &baremetal.ListOptions{}
75-
opts.Limit = 1
76-
opts.Page = "page"
77-
78-
s.Client.On("ListDHCPOptions", "compartment_id", "vcn_id", opts).Return(s.List, nil)
79-
8048
resource.UnitTest(s.T(), resource.TestCase{
8149
PreventPostDestroyRefresh: true,
8250
Providers: s.Providers,
@@ -99,51 +67,6 @@ func (s *ResourceCoreDHCPOptionsDatasourceTestSuite) TestReadDHCPOptions() {
9967
},
10068
)
10169

102-
s.Client.AssertCalled(s.T(), "ListDHCPOptions", "compartment_id", "vcn_id", opts)
103-
}
104-
105-
func (s *ResourceCoreDHCPOptionsDatasourceTestSuite) TestReadDHCPOptionsWithPagination() {
106-
opts := &baremetal.ListOptions{}
107-
opts.Limit = 1
108-
opts.Page = "page"
109-
110-
listVal := *s.List
111-
list := &listVal
112-
list.NextPage = "nextpage"
113-
s.Client.On("ListDHCPOptions", "compartment_id", "vcn_id", opts).Return(list, nil)
114-
115-
opts2 := &baremetal.ListOptions{}
116-
opts2.Limit = 1
117-
opts2.Page = "nextpage"
118-
119-
list2Val := *s.List
120-
list2 := &list2Val
121-
b3 := s.List.DHCPOptions[0]
122-
b3.ID = "id3"
123-
b4 := s.List.DHCPOptions[1]
124-
b4.ID = "id4"
125-
list2.DHCPOptions = []baremetal.DHCPOptions{b3, b4}
126-
s.Client.On("ListDHCPOptions", "compartment_id", "vcn_id", opts2).Return(list2, nil)
127-
128-
resource.UnitTest(s.T(), resource.TestCase{
129-
PreventPostDestroyRefresh: true,
130-
Providers: s.Providers,
131-
Steps: []resource.TestStep{
132-
{
133-
ImportState: true,
134-
ImportStateVerify: true,
135-
Config: s.Config,
136-
Check: resource.ComposeTestCheckFunc(
137-
resource.TestCheckResourceAttr(s.ResourceName, "options.0.id", "id1"),
138-
resource.TestCheckResourceAttr(s.ResourceName, "options.3.id", "id4"),
139-
resource.TestCheckResourceAttr(s.ResourceName, "options.#", "4"),
140-
),
141-
},
142-
},
143-
},
144-
)
145-
146-
s.Client.AssertCalled(s.T(), "ListDHCPOptions", "compartment_id", "vcn_id", opts2)
14770
}
14871

14972
func TestResourceCoreDHCPOptionsDatasourceTestSuite(t *testing.T) {

data_source_obmcs_core_drg_attachment_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ package main
44

55
import (
66
"testing"
7+
78
"github.com/hashicorp/terraform/helper/resource"
89
"github.com/hashicorp/terraform/helper/schema"
910
"github.com/hashicorp/terraform/terraform"

data_source_obmcs_core_drg_test.go

Lines changed: 2 additions & 130 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,11 @@ package main
44

55
import (
66
"testing"
7-
"time"
87

9-
"github.com/MustWin/baremetal-sdk-go"
108
"github.com/hashicorp/terraform/helper/resource"
119
"github.com/hashicorp/terraform/helper/schema"
1210
"github.com/hashicorp/terraform/terraform"
1311

14-
15-
16-
1712
"github.com/stretchr/testify/suite"
1813
)
1914

@@ -47,120 +42,6 @@ func (s *ResourceCoreDrgsTestSuite) SetupTest() {
4742
}
4843

4944
func (s *ResourceCoreDrgsTestSuite) TestReadDrgs() {
50-
opts := &baremetal.ListOptions{}
51-
opts.Limit = 1
52-
opts.Page = "page"
53-
54-
s.Client.On(
55-
"ListDrgs",
56-
"compartment_id",
57-
opts,
58-
).Return(
59-
&baremetal.ListDrgs{
60-
Drgs: []baremetal.Drg{
61-
{
62-
CompartmentID: "compartment_id",
63-
DisplayName: "display_name",
64-
ID: "id1",
65-
State: baremetal.ResourceAttached,
66-
TimeCreated: baremetal.Time{Time: time.Now()},
67-
},
68-
{
69-
CompartmentID: "compartment_id",
70-
DisplayName: "display_name",
71-
ID: "id2",
72-
State: baremetal.ResourceAttached,
73-
TimeCreated: baremetal.Time{Time: time.Now()},
74-
},
75-
},
76-
},
77-
nil,
78-
)
79-
80-
resource.UnitTest(s.T(), resource.TestCase{
81-
PreventPostDestroyRefresh: true,
82-
Providers: s.Providers,
83-
Steps: []resource.TestStep{
84-
{
85-
ImportState: true,
86-
ImportStateVerify: true,
87-
Config: s.Config,
88-
Check: resource.ComposeTestCheckFunc(
89-
90-
resource.TestCheckResourceAttr(s.ResourceName, "limit", "1"),
91-
resource.TestCheckResourceAttr(s.ResourceName, "page", "page"),
92-
resource.TestCheckResourceAttr(s.ResourceName, "drgs.0.compartment_id", "compartment_id"),
93-
resource.TestCheckResourceAttr(s.ResourceName, "drgs.0.id", "id1"),
94-
resource.TestCheckResourceAttr(s.ResourceName, "drgs.1.id", "id2"),
95-
resource.TestCheckResourceAttr(s.ResourceName, "drgs.#", "2"),
96-
),
97-
},
98-
},
99-
},
100-
)
101-
102-
s.Client.AssertCalled(s.T(), "ListDrgs", "compartment_id", opts)
103-
}
104-
105-
func (s *ResourceCoreDrgsTestSuite) TestReadDrgsPaged() {
106-
opts := &baremetal.ListOptions{}
107-
opts.Limit = 1
108-
opts.Page = "page"
109-
110-
res := &baremetal.ListDrgs{}
111-
res.NextPage = "nextpage"
112-
res.Drgs = []baremetal.Drg{
113-
{
114-
CompartmentID: "compartment_id",
115-
DisplayName: "display_name",
116-
ID: "id1",
117-
State: baremetal.ResourceAttached,
118-
TimeCreated: baremetal.Time{Time: time.Now()},
119-
},
120-
{
121-
CompartmentID: "compartment_id",
122-
DisplayName: "display_name",
123-
ID: "id2",
124-
State: baremetal.ResourceAttached,
125-
TimeCreated: baremetal.Time{Time: time.Now()},
126-
},
127-
}
128-
129-
s.Client.On(
130-
"ListDrgs",
131-
"compartment_id",
132-
opts,
133-
).Return(res, nil)
134-
135-
opts2 := &baremetal.ListOptions{}
136-
opts2.Page = "nextpage"
137-
opts2.Limit = 1
138-
139-
s.Client.On(
140-
"ListDrgs",
141-
"compartment_id",
142-
opts2,
143-
).Return(
144-
&baremetal.ListDrgs{
145-
Drgs: []baremetal.Drg{
146-
{
147-
CompartmentID: "compartment_id",
148-
DisplayName: "display_name",
149-
ID: "id3",
150-
State: baremetal.ResourceAttached,
151-
TimeCreated: baremetal.Time{Time: time.Now()},
152-
},
153-
{
154-
CompartmentID: "compartment_id",
155-
DisplayName: "display_name",
156-
ID: "id4",
157-
State: baremetal.ResourceAttached,
158-
TimeCreated: baremetal.Time{Time: time.Now()},
159-
},
160-
},
161-
},
162-
nil,
163-
)
16445

16546
resource.UnitTest(s.T(), resource.TestCase{
16647
PreventPostDestroyRefresh: true,
@@ -171,23 +52,14 @@ func (s *ResourceCoreDrgsTestSuite) TestReadDrgsPaged() {
17152
ImportStateVerify: true,
17253
Config: s.Config,
17354
Check: resource.ComposeTestCheckFunc(
174-
175-
resource.TestCheckResourceAttr(s.ResourceName, "limit", "1"),
176-
resource.TestCheckResourceAttr(s.ResourceName, "page", "page"),
177-
resource.TestCheckResourceAttr(s.ResourceName, "drgs.0.compartment_id", "compartment_id"),
178-
resource.TestCheckResourceAttr(s.ResourceName, "drgs.0.id", "id1"),
179-
resource.TestCheckResourceAttr(s.ResourceName, "drgs.1.id", "id2"),
180-
resource.TestCheckResourceAttr(s.ResourceName, "drgs.#", "4"),
181-
resource.TestCheckResourceAttr(s.ResourceName, "drgs.2.id", "id3"),
182-
resource.TestCheckResourceAttr(s.ResourceName, "drgs.3.id", "id4"),
55+
resource.TestCheckResourceAttrSet(s.ResourceName, "drgs.0.id"),
56+
resource.TestCheckResourceAttrSet(s.ResourceName, "drgs.#"),
18357
),
18458
},
18559
},
18660
},
18761
)
18862

189-
s.Client.AssertCalled(s.T(), "ListDrgs", "compartment_id", opts2)
190-
19163
}
19264

19365
func TestResourceCoreDrgsTestSuite(t *testing.T) {

0 commit comments

Comments
 (0)