@@ -20,35 +20,31 @@ func TestCreateSuccessful(t *testing.T) {
2020 th .Mux .HandleFunc ("/endpoints" , func (w http.ResponseWriter , r * http.Request ) {
2121 th .TestMethod (t , r , "POST" )
2222 th .TestHeader (t , r , "X-Auth-Token" , client .TokenID )
23- th .TestJSONRequest (t , r , `
24- {
25- "endpoint": {
26- "interface": "public",
27- "name": "the-endiest-of-points",
28- "region": "underground",
29- "url": "https://1.2.3.4:9000/",
30- "service_id": "asdfasdfasdfasdf"
31- }
32- }
33- ` )
23+ th .TestJSONRequest (t , r , `{
24+ "endpoint": {
25+ "interface": "public",
26+ "name": "the-endiest-of-points",
27+ "region": "underground",
28+ "url": "https://1.2.3.4:9000/",
29+ "service_id": "asdfasdfasdfasdf"
30+ }
31+ }` )
3432
3533 w .WriteHeader (http .StatusCreated )
36- fmt .Fprint (w , `
37- {
38- "endpoint": {
39- "id": "12",
40- "interface": "public",
41- "enabled": true,
42- "links": {
43- "self": "https://localhost:5000/v3/endpoints/12"
44- },
45- "name": "the-endiest-of-points",
46- "region": "underground",
47- "service_id": "asdfasdfasdfasdf",
48- "url": "https://1.2.3.4:9000/"
49- }
50- }
51- ` )
34+ fmt .Fprint (w , `{
35+ "endpoint": {
36+ "id": "12",
37+ "interface": "public",
38+ "enabled": true,
39+ "links": {
40+ "self": "https://localhost:5000/v3/endpoints/12"
41+ },
42+ "name": "the-endiest-of-points",
43+ "region": "underground",
44+ "service_id": "asdfasdfasdfasdf",
45+ "url": "https://1.2.3.4:9000/"
46+ }
47+ }` )
5248 })
5349
5450 actual , err := endpoints .Create (context .TODO (), client .ServiceClient (), endpoints.CreateOpts {
@@ -82,40 +78,38 @@ func TestListEndpoints(t *testing.T) {
8278 th .TestHeader (t , r , "X-Auth-Token" , client .TokenID )
8379
8480 w .Header ().Add ("Content-Type" , "application/json" )
85- fmt .Fprint (w , `
86- {
87- "endpoints": [
88- {
89- "id": "12",
90- "interface": "public",
91- "enabled": true,
92- "links": {
93- "self": "https://localhost:5000/v3/endpoints/12"
94- },
95- "name": "the-endiest-of-points",
96- "region": "underground",
97- "service_id": "asdfasdfasdfasdf",
98- "url": "https://1.2.3.4:9000/"
81+ fmt .Fprint (w , `{
82+ "endpoints": [
83+ {
84+ "id": "12",
85+ "interface": "public",
86+ "enabled": true,
87+ "links": {
88+ "self": "https://localhost:5000/v3/endpoints/12"
9989 },
100- {
101- "id ": "13 ",
102- "interface ": "internal ",
103- "enabled ": false,
104- "links": {
105- "self": "https://localhost:5000/v3/endpoints/13"
106- } ,
107- "name ": "shhhh ",
108- "region ": "underground" ,
109- "service_id ": "asdfasdfasdfasdf",
110- "url ": "https://1.2.3.4:9001/ "
111- }
112- ] ,
113- "links ": {
114- "next ": null ,
115- "previous ": null
90+ "name": "the-endiest-of-points",
91+ "region ": "underground ",
92+ "service_id ": "asdfasdfasdfasdf ",
93+ "url ": "https://1.2.3.4:9000/"
94+ },
95+ {
96+ "id": "13" ,
97+ "interface ": "internal ",
98+ "enabled ": false ,
99+ "links ": {
100+ "self ": "https://localhost:5000/v3/endpoints/13 "
101+ },
102+ "name": "shhhh" ,
103+ "region ": "underground",
104+ "service_id ": "asdfasdfasdfasdf" ,
105+ "url ": "https://1.2.3.4:9001/"
116106 }
107+ ],
108+ "links": {
109+ "next": null,
110+ "previous": null
117111 }
118- ` )
112+ } ` )
119113 })
120114
121115 count := 0
@@ -154,24 +148,62 @@ func TestListEndpoints(t *testing.T) {
154148 th .AssertEquals (t , 1 , count )
155149}
156150
151+ func TestGetEndpoint (t * testing.T ) {
152+ th .SetupHTTP ()
153+ defer th .TeardownHTTP ()
154+
155+ th .Mux .HandleFunc ("/endpoints/12" , func (w http.ResponseWriter , r * http.Request ) {
156+ th .TestMethod (t , r , "GET" )
157+ th .TestHeader (t , r , "X-Auth-Token" , client .TokenID )
158+
159+ fmt .Fprint (w , `{
160+ "endpoint": {
161+ "id": "12",
162+ "interface": "public",
163+ "enabled": true,
164+ "links": {
165+ "self": "https://localhost:5000/v3/endpoints/12"
166+ },
167+ "name": "the-endiest-of-points",
168+ "region": "underground",
169+ "service_id": "asdfasdfasdfasdf",
170+ "url": "https://1.2.3.4:9000/"
171+ }
172+ }` )
173+ })
174+
175+ actual , err := endpoints .Get (context .TODO (), client .ServiceClient (), "12" ).Extract ()
176+ if err != nil {
177+ t .Fatalf ("Unexpected error from Get: %v" , err )
178+ }
179+
180+ expected := & endpoints.Endpoint {
181+ ID : "12" ,
182+ Availability : gophercloud .AvailabilityPublic ,
183+ Enabled : true ,
184+ Name : "the-endiest-of-points" ,
185+ Region : "underground" ,
186+ ServiceID : "asdfasdfasdfasdf" ,
187+ URL : "https://1.2.3.4:9000/" ,
188+ }
189+ th .AssertDeepEquals (t , expected , actual )
190+ }
191+
157192func TestUpdateEndpoint (t * testing.T ) {
158193 th .SetupHTTP ()
159194 defer th .TeardownHTTP ()
160195
161196 th .Mux .HandleFunc ("/endpoints/12" , func (w http.ResponseWriter , r * http.Request ) {
162197 th .TestMethod (t , r , "PATCH" )
163198 th .TestHeader (t , r , "X-Auth-Token" , client .TokenID )
164- th .TestJSONRequest (t , r , `
165- {
166- "endpoint": {
167- "name": "renamed",
199+ th .TestJSONRequest (t , r , `{
200+ "endpoint": {
201+ "name": "renamed",
168202 "region": "somewhere-else"
169- }
170- }
171- ` )
203+ }
204+ }` )
172205
173- fmt .Fprint (w , `
174- {
206+ fmt .Fprint (w , `{
175207 "endpoint": {
176208 "id": "12",
177209 "interface": "public",
@@ -184,8 +216,7 @@ func TestUpdateEndpoint(t *testing.T) {
184216 "service_id": "asdfasdfasdfasdf",
185217 "url": "https://1.2.3.4:9000/"
186218 }
187- }
188- ` )
219+ }` )
189220 })
190221
191222 actual , err := endpoints .Update (context .TODO (), client .ServiceClient (), "12" , endpoints.UpdateOpts {
0 commit comments