@@ -10,6 +10,37 @@ import (
1010 "github.com/gophercloud/gophercloud/testhelper/client"
1111)
1212
13+ // ListAvailableOutput provides a single page of available domain results.
14+ const ListAvailableOutput = `
15+ {
16+ "domains": [
17+ {
18+ "id": "52af04aec5f84182b06959d2775d2000",
19+ "name": "TestDomain",
20+ "description": "Testing domain",
21+ "enabled": false,
22+ "links": {
23+ "self": "https://example.com/v3/domains/52af04aec5f84182b06959d2775d2000"
24+ }
25+ },
26+ {
27+ "id": "a720688fb87f4575a4c000d818061eae",
28+ "name": "ProdDomain",
29+ "description": "Production domain",
30+ "enabled": true,
31+ "links": {
32+ "self": "https://example.com/v3/domains/a720688fb87f4575a4c000d818061eae"
33+ }
34+ }
35+ ],
36+ "links": {
37+ "next": null,
38+ "self": "https://example.com/v3/auth/domains",
39+ "previous": null
40+ }
41+ }
42+ `
43+
1344// ListOutput provides a single page of Domain results.
1445const ListOutput = `
1546{
@@ -87,6 +118,28 @@ const UpdateOutput = `
87118}
88119`
89120
121+ // ProdDomain is a domain fixture.
122+ var ProdDomain = domains.Domain {
123+ Enabled : true ,
124+ ID : "a720688fb87f4575a4c000d818061eae" ,
125+ Links : map [string ]interface {}{
126+ "self" : "https://example.com/v3/domains/a720688fb87f4575a4c000d818061eae" ,
127+ },
128+ Name : "ProdDomain" ,
129+ Description : "Production domain" ,
130+ }
131+
132+ // TestDomain is a domain fixture.
133+ var TestDomain = domains.Domain {
134+ Enabled : false ,
135+ ID : "52af04aec5f84182b06959d2775d2000" ,
136+ Links : map [string ]interface {}{
137+ "self" : "https://example.com/v3/domains/52af04aec5f84182b06959d2775d2000" ,
138+ },
139+ Name : "TestDomain" ,
140+ Description : "Testing domain" ,
141+ }
142+
90143// FirstDomain is the first domain in the List request.
91144var FirstDomain = domains.Domain {
92145 Enabled : true ,
@@ -119,9 +172,27 @@ var SecondDomainUpdated = domains.Domain{
119172 Description : "Staging Domain" ,
120173}
121174
175+ // ExpectedAvailableDomainsSlice is the slice of domains expected to be returned
176+ // from ListAvailableOutput.
177+ var ExpectedAvailableDomainsSlice = []domains.Domain {TestDomain , ProdDomain }
178+
122179// ExpectedDomainsSlice is the slice of domains expected to be returned from ListOutput.
123180var ExpectedDomainsSlice = []domains.Domain {FirstDomain , SecondDomain }
124181
182+ // HandleListAvailableDomainsSuccessfully creates an HTTP handler at `/auth/domains`
183+ // on the test handler mux that responds with a list of two domains.
184+ func HandleListAvailableDomainsSuccessfully (t * testing.T ) {
185+ th .Mux .HandleFunc ("/auth/domains" , func (w http.ResponseWriter , r * http.Request ) {
186+ th .TestMethod (t , r , "GET" )
187+ th .TestHeader (t , r , "Accept" , "application/json" )
188+ th .TestHeader (t , r , "X-Auth-Token" , client .TokenID )
189+
190+ w .Header ().Set ("Content-Type" , "application/json" )
191+ w .WriteHeader (http .StatusOK )
192+ fmt .Fprintf (w , ListAvailableOutput )
193+ })
194+ }
195+
125196// HandleListDomainsSuccessfully creates an HTTP handler at `/domains` on the
126197// test handler mux that responds with a list of two domains.
127198func HandleListDomainsSuccessfully (t * testing.T ) {
0 commit comments