forked from jpillora/go-dropbox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
client_test.go
40 lines (30 loc) · 799 Bytes
/
client_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
package dropbox
import (
"testing"
"github.com/segmentio/go-env"
"github.com/stretchr/testify/assert"
)
func client() *Client {
token := env.MustGet("DROPBOX_ACCESS_TOKEN")
return New(NewConfig(token))
}
func TestClient_error_text(t *testing.T) {
c := client()
_, err := c.Files.Download(&DownloadInput{
Path: "asdfasdfasdf",
})
assert.Error(t, err)
e := err.(*Error)
assert.Contains(t, e.Error(), "Error in call")
assert.Equal(t, "Bad Request", e.Status)
assert.Equal(t, 400, e.StatusCode)
}
func TestClient_error_json(t *testing.T) {
c := client()
_, err := c.Files.Download(&DownloadInput{"/nothing"})
assert.Error(t, err)
e := err.(*Error)
assert.Contains(t, e.Error(), "path/not_found")
assert.Equal(t, "Conflict", e.Status)
assert.Equal(t, 409, e.StatusCode)
}