-
Notifications
You must be signed in to change notification settings - Fork 1
/
annotations_test.go
53 lines (43 loc) · 1.33 KB
/
annotations_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
package books
import (
"fmt"
"net/http"
"reflect"
"testing"
)
func TestAnnotations_List(t *testing.T) {
setup()
defer teardown()
mux.HandleFunc("/mylibrary/annotations", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
fmt.Fprint(w, `{"totalItems":1,"items":[{"volumeId":"VN2jCgAAAEAJ","layerId":"notes","selectedText":"Go"}]}`)
})
opts := &AnnotationsListOptions{
VolumeID: "SJHvCgAAQBAJ",
ContentVersion: "test11",
LayerID: "notes",
Source: "ge-web-app1",
}
list, _, err := client.Annotations.List(opts)
if err != nil {
t.Errorf("List() returned an error: %v", err)
}
expected := []Annotation{{VolumeID: String("VN2jCgAAAEAJ"), LayerID: String("notes"), SelectedText: String("Go")}}
if !reflect.DeepEqual(list, expected) {
t.Errorf("List() returned %+v, expected %+v", list, expected)
}
}
func TestAnnotationsList_badBody(t *testing.T) {
setup()
defer teardown()
opts := &AnnotationsListOptions{}
_, resp, err := client.Annotations.List(opts)
// Check that response is error on nil request body
if err == nil {
t.Error("List() Expected Request body error.")
}
// Check that response status code is http.StatusNotFound.
if got, want := resp.StatusCode, http.StatusNotFound; got != want {
t.Errorf("List() Expected Status code got %v, want %v", got, want)
}
}