forked from tj/go-dropbox
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient_test.go
More file actions
43 lines (32 loc) · 856 Bytes
/
client_test.go
File metadata and controls
43 lines (32 loc) · 856 Bytes
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
package dropbox
import (
"context"
"testing"
env "github.com/segmentio/go-env"
"github.com/stretchr/testify/assert"
)
var ctx = context.Background()
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(ctx, &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(ctx, &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)
}