blob: 206290f34ea3b1b75478e3a111e8983da6a879b4 [file] [log] [blame]
Samuel A. Falvo II2e2b8772013-07-04 15:40:15 -07001package gophercloud
2
3import (
4 "net/http"
5 "testing"
6)
7
8type testAccess struct {
9 public, internal string
10 calledFirstEndpointByCriteria int
11}
12
13func (ta *testAccess) FirstEndpointUrlByCriteria(ac ApiCriteria) string {
14 ta.calledFirstEndpointByCriteria++
15 urls := []string{ta.public, ta.internal}
16 return urls[ac.UrlChoice]
17}
18
19func TestGetServersApi(t *testing.T) {
20 c := TestContext().UseCustomClient(&http.Client{Transport: newTransport().WithResponse("Hello")})
21
22 acc := &testAccess{
23 public: "http://localhost:8080",
24 internal: "http://localhost:8086",
25 }
26
27 _, err := c.ComputeApi(acc, ApiCriteria{
28 Name: "cloudComputeOpenStack",
29 Region: "dfw",
30 VersionId: "2",
31 })
32
33 if err != nil {
34 t.Error(err)
35 return
36 }
37
38 if acc.calledFirstEndpointByCriteria != 1 {
39 t.Error("Expected FirstEndpointByCriteria to be called")
40 return
41 }
42}