forked from rackspace/gophercloud
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathservers_test.go
54 lines (43 loc) · 1.02 KB
/
servers_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
package gophercloud
import (
"net/http"
"testing"
)
type testAccess struct {
public, internal string
calledFirstEndpointByCriteria int
}
func (ta *testAccess) FirstEndpointUrlByCriteria(ac ApiCriteria) string {
ta.calledFirstEndpointByCriteria++
urls := []string{ta.public, ta.internal}
return urls[ac.UrlChoice]
}
func (ta *testAccess) AuthToken() string {
return ""
}
func (ta *testAccess) Revoke(string) error {
return nil
}
func (ta *testAccess) Reauthenticate() error {
return nil
}
func TestGetServersApi(t *testing.T) {
c := TestContext().UseCustomClient(&http.Client{Transport: newTransport().WithResponse("Hello")})
acc := &testAccess{
public: "http://localhost:8080",
internal: "http://localhost:8086",
}
_, err := c.ServersApi(acc, ApiCriteria{
Name: "cloudComputeOpenStack",
Region: "dfw",
VersionId: "2",
})
if err != nil {
t.Error(err)
return
}
if acc.calledFirstEndpointByCriteria != 1 {
t.Error("Expected FirstEndpointByCriteria to be called")
return
}
}