forked from linode/linodego
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresources_test.go
44 lines (35 loc) · 1.08 KB
/
resources_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
package linodego
import (
"context"
"fmt"
"testing"
"golang.org/x/oauth2"
)
func TestResourceEndpoint(t *testing.T) {
apiKey := "MYFAKEAPIKEY"
tokenSource := oauth2.StaticTokenSource(&oauth2.Token{AccessToken: apiKey})
oc := oauth2.NewClient(context.Background(), tokenSource)
client := NewClient(oc)
r := client.Resource("images")
e, err := r.Endpoint()
if err != nil {
t.Error("Got error when querying for images endpoint")
}
if e != imagesEndpoint {
t.Errorf("Images endpoint did not match '%s'", imagesEndpoint)
}
}
func TestResourceTemplatedendpointWithID(t *testing.T) {
apiKey := "MYFAKEAPIKEY"
tokenSource := oauth2.StaticTokenSource(&oauth2.Token{AccessToken: apiKey})
oc := oauth2.NewClient(context.Background(), tokenSource)
client := NewClient(oc)
backupID := 1234255
e, err := client.InstanceSnapshots.endpointWithParams(backupID)
if err != nil {
t.Error("Got error when getting endpoint with id for backups")
}
if e != fmt.Sprintf("linode/instances/%d/backups", backupID) {
t.Errorf("Backups endpoint did not contain backup ID '%d'", backupID)
}
}