forked from kothar/go-backblaze
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuckets_test.go
53 lines (46 loc) · 1.07 KB
/
buckets_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 backblaze
import (
"testing"
)
func TestListBuckets(T *testing.T) {
accountID := "test"
bucketID := "bucketid"
client, server := prepareResponses([]response{
{code: 200, body: authorizeAccountResponse{
AccountID: accountID,
APIEndpoint: "http://api.url",
AuthorizationToken: "testToken",
DownloadURL: "http://download.url",
}},
{code: 200, body: listBucketsResponse{
Buckets: []*BucketInfo{
&BucketInfo{
ID: bucketID,
AccountID: accountID,
Name: "testbucket",
BucketType: AllPrivate,
},
},
}},
})
defer server.Close()
b2 := &B2{
Credentials: Credentials{
AccountID: accountID,
ApplicationKey: "test",
},
Debug: testing.Verbose(),
httpClient: *client,
host: server.URL,
}
buckets, err := b2.ListBuckets()
if err != nil {
T.Fatal(err)
}
if len(buckets) != 1 {
T.Errorf("Expected 1 bucket, received %d", len(buckets))
}
if buckets[0].ID != bucketID {
T.Errorf("Bucket ID does not match: expected %q, saw %q", bucketID, buckets[0].ID)
}
}