forked from TrueCloudLab/rclone
Switch to using the dep tool and update all the dependencies
This commit is contained in:
parent
5135ff73cb
commit
98c2d2c41b
5321 changed files with 4483201 additions and 5922 deletions
115
vendor/github.com/ncw/go-acd/account_test.go
generated
vendored
Normal file
115
vendor/github.com/ncw/go-acd/account_test.go
generated
vendored
Normal file
|
@ -0,0 +1,115 @@
|
|||
// Copyright (c) 2015 Serge Gebhardt. All rights reserved.
|
||||
//
|
||||
// Use of this source code is governed by the ISC
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package acd
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestAccount_getInfo(t *testing.T) {
|
||||
r := *NewMockResponseOkString(`{ "termsOfUse": "1.0.0", "status": "ACTIVE" }`)
|
||||
c := NewMockClient(r)
|
||||
|
||||
info, _, err := c.Account.GetInfo()
|
||||
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, "ACTIVE", *info.Status)
|
||||
assert.Equal(t, "1.0.0", *info.TermsOfUse)
|
||||
}
|
||||
|
||||
func TestAccount_getQuota(t *testing.T) {
|
||||
r := *NewMockResponseOkString(`
|
||||
{
|
||||
"quota": 5368709120,
|
||||
"lastCalculated": "2014-08-13T23:01:47.479Z",
|
||||
"available": 4069088896
|
||||
}
|
||||
`)
|
||||
c := NewMockClient(r)
|
||||
|
||||
quota, _, err := c.Account.GetQuota()
|
||||
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, "2014-08-13 23:01:47.479 +0000 UTC", quota.LastCalculated.String())
|
||||
assert.Equal(t, uint64(5368709120), *quota.Quota)
|
||||
assert.Equal(t, uint64(4069088896), *quota.Available)
|
||||
}
|
||||
|
||||
func TestAccount_getUsage(t *testing.T) {
|
||||
r := *NewMockResponseOkString(`
|
||||
{
|
||||
"lastCalculated":"2014-08-13T23:17:41.365Z",
|
||||
"other":{
|
||||
"total":{
|
||||
"bytes":29999771,
|
||||
"count":871
|
||||
},
|
||||
"billable":{
|
||||
"bytes":29999771,
|
||||
"count":871
|
||||
}
|
||||
},
|
||||
"doc":{
|
||||
"total":{
|
||||
"bytes":807170,
|
||||
"count":10
|
||||
},
|
||||
"billable":{
|
||||
"bytes":807170,
|
||||
"count":10
|
||||
}
|
||||
},
|
||||
"photo":{
|
||||
"total":{
|
||||
"bytes":9477988,
|
||||
"count":25
|
||||
},
|
||||
"billable":{
|
||||
"bytes":9477988,
|
||||
"count":25
|
||||
}
|
||||
},
|
||||
"video":{
|
||||
"total":{
|
||||
"bytes":23524252,
|
||||
"count":22
|
||||
},
|
||||
"billable":{
|
||||
"bytes":23524252,
|
||||
"count":22
|
||||
}
|
||||
}
|
||||
}
|
||||
`)
|
||||
c := NewMockClient(r)
|
||||
|
||||
usage, _, err := c.Account.GetUsage()
|
||||
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, "2014-08-13 23:17:41.365 +0000 UTC", usage.LastCalculated.String())
|
||||
|
||||
assert.Equal(t, uint64(29999771), *usage.Other.Total.Bytes)
|
||||
assert.Equal(t, uint64(871), *usage.Other.Total.Count)
|
||||
assert.Equal(t, uint64(29999771), *usage.Other.Billable.Bytes)
|
||||
assert.Equal(t, uint64(871), *usage.Other.Billable.Count)
|
||||
|
||||
assert.Equal(t, uint64(807170), *usage.Doc.Total.Bytes)
|
||||
assert.Equal(t, uint64(10), *usage.Doc.Total.Count)
|
||||
assert.Equal(t, uint64(807170), *usage.Doc.Billable.Bytes)
|
||||
assert.Equal(t, uint64(10), *usage.Doc.Billable.Count)
|
||||
|
||||
assert.Equal(t, uint64(9477988), *usage.Photo.Total.Bytes)
|
||||
assert.Equal(t, uint64(25), *usage.Photo.Total.Count)
|
||||
assert.Equal(t, uint64(9477988), *usage.Photo.Billable.Bytes)
|
||||
assert.Equal(t, uint64(25), *usage.Photo.Billable.Count)
|
||||
|
||||
assert.Equal(t, uint64(23524252), *usage.Video.Total.Bytes)
|
||||
assert.Equal(t, uint64(22), *usage.Video.Total.Count)
|
||||
assert.Equal(t, uint64(23524252), *usage.Video.Billable.Bytes)
|
||||
assert.Equal(t, uint64(22), *usage.Video.Billable.Count)
|
||||
}
|
56
vendor/github.com/ncw/go-acd/client_mock_test.go
generated
vendored
Normal file
56
vendor/github.com/ncw/go-acd/client_mock_test.go
generated
vendored
Normal file
|
@ -0,0 +1,56 @@
|
|||
// Copyright (c) 2015 Serge Gebhardt. All rights reserved.
|
||||
//
|
||||
// Use of this source code is governed by the ISC
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package acd
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// MockResponse is a static HTTP response.
|
||||
type MockResponse struct {
|
||||
Code int
|
||||
Body []byte
|
||||
}
|
||||
|
||||
// NewMockResponseOkString creates a new MockResponse with Code 200 (OK)
|
||||
// and Body built from string argument
|
||||
func NewMockResponseOkString(response string) *MockResponse {
|
||||
return &MockResponse{
|
||||
Code: 200,
|
||||
Body: []byte(response),
|
||||
}
|
||||
}
|
||||
|
||||
// mockTransport is a mocked Transport that always returns the same MockResponse.
|
||||
type mockTransport struct {
|
||||
resp MockResponse
|
||||
}
|
||||
|
||||
// Satisfies the RoundTripper interface.
|
||||
func (t *mockTransport) RoundTrip(req *http.Request) (*http.Response, error) {
|
||||
r := http.Response{
|
||||
StatusCode: t.resp.Code,
|
||||
Proto: "HTTP/1.0",
|
||||
ProtoMajor: 1,
|
||||
ProtoMinor: 0,
|
||||
}
|
||||
|
||||
if len(t.resp.Body) > 0 {
|
||||
buf := bytes.NewBuffer(t.resp.Body)
|
||||
r.Body = ioutil.NopCloser(buf)
|
||||
}
|
||||
|
||||
return &r, nil
|
||||
}
|
||||
|
||||
// MockClient is a mocked Client that is used for tests.
|
||||
func NewMockClient(response MockResponse) *Client {
|
||||
t := &mockTransport{resp: response}
|
||||
c := &http.Client{Transport: t}
|
||||
return NewClient(c)
|
||||
}
|
157
vendor/github.com/ncw/go-acd/nodes_test.go
generated
vendored
Normal file
157
vendor/github.com/ncw/go-acd/nodes_test.go
generated
vendored
Normal file
|
@ -0,0 +1,157 @@
|
|||
// Copyright (c) 2015 Serge Gebhardt. All rights reserved.
|
||||
//
|
||||
// Use of this source code is governed by the ISC
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package acd
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestNode_getRoot(t *testing.T) {
|
||||
r := *NewMockResponseOkString(`
|
||||
{
|
||||
"count":1,
|
||||
"data":[
|
||||
{
|
||||
"isRoot":true,
|
||||
"eTagResponse":"LMel82iwbNk",
|
||||
"id":"3ohaT2SSQWOecmP0GSWv6g",
|
||||
"kind":"FOLDER",
|
||||
"version":156,
|
||||
"labels":[
|
||||
|
||||
],
|
||||
"createdDate":"2014-04-08T20:58:58.011Z",
|
||||
"createdBy":"CloudDriveFiles",
|
||||
"restricted":false,
|
||||
"modifiedDate":"2015-05-03T16:12:35.394Z",
|
||||
"isShared":false,
|
||||
"parents":[
|
||||
|
||||
],
|
||||
"status":"AVAILABLE"
|
||||
}
|
||||
]
|
||||
}
|
||||
`)
|
||||
c := NewMockClient(r)
|
||||
|
||||
root, _, err := c.Nodes.GetRoot()
|
||||
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, "3ohaT2SSQWOecmP0GSWv6g", *root.Id)
|
||||
assert.Nil(t, root.Name)
|
||||
}
|
||||
|
||||
func TestNode_getNodes(t *testing.T) {
|
||||
r := *NewMockResponseOkString(`
|
||||
{
|
||||
"count":2,
|
||||
"nextToken":"kgkbpodpt6",
|
||||
"data":[
|
||||
{
|
||||
"eTagResponse":"eodh1-sfNbMI",
|
||||
"id":"eRkZ6YMuX5W3VqV3Ia7_lf",
|
||||
"name":"fooNew.jpg",
|
||||
"kind":"FILE",
|
||||
"metadataVersion":1,
|
||||
"modifiedDate":"2014-03-07T22:31:12.173Z",
|
||||
"creationDate":"2014-03-07T22:31:12.173Z",
|
||||
"labels":[
|
||||
"PHOTO"
|
||||
],
|
||||
"description":"My Awesome Photo",
|
||||
"createdBy":"ApplicationId1",
|
||||
"parents":[
|
||||
"foo1",
|
||||
"123"
|
||||
],
|
||||
"status":"Available",
|
||||
"restricted":false,
|
||||
"size":56654,
|
||||
"contentType":"image/jpeg",
|
||||
"md5":"6df23dc03f9b54cc38a0fc1483df6e21",
|
||||
"fileExtension":"jpeg",
|
||||
"contentProperties":{
|
||||
"image":{
|
||||
"make":"SAMSUNG",
|
||||
"model":"SAMSUNG-SGH-I747",
|
||||
"exposureTime":"1/1780",
|
||||
"dateTimeOriginal":"2012-08-25T14:23:24.000Z",
|
||||
"flash":"No",
|
||||
"focalLength":"37/10",
|
||||
"dateTime":"2012-08-25T14:23:24.000Z",
|
||||
"dateTimeDigitized":"2012-08-25T14:23:24.000Z",
|
||||
"software":"I747UCALG1",
|
||||
"orientation":"1",
|
||||
"colorSpace":"sRGB",
|
||||
"meteringMode":"CenterWeightedAverage",
|
||||
"exposureProgram":"Aperture Priority",
|
||||
"exposureMode":"Auto Exposure",
|
||||
"whiteBalance":"Auto",
|
||||
"sensingMethod":"One-chip color area",
|
||||
"xResolution":"72",
|
||||
"yResolution":"72",
|
||||
"resolutionUnit":"Pixels/Inch"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"eTagResponse":"sdgrrtbbfdd",
|
||||
"id":"fooo1",
|
||||
"name":"foo.zip",
|
||||
"kind":"FILE",
|
||||
"metadataVersion":1,
|
||||
"modifiedDate":"2014-03-07T22:31:12.173Z",
|
||||
"creationDate":"2014-03-07T22:31:12.173Z",
|
||||
"labels":[
|
||||
"ZIP File"
|
||||
],
|
||||
"description":"All My Data",
|
||||
"createdBy":"ApplicationId2",
|
||||
"status":"Available",
|
||||
"restricted":false,
|
||||
"size":5665423,
|
||||
"contentType":"application/octet-stream",
|
||||
"md5":"6df23dc03f9b54cc38a0fc1483df6e23",
|
||||
"fileExtension":"zip"
|
||||
}
|
||||
]
|
||||
}
|
||||
`)
|
||||
c := NewMockClient(r)
|
||||
opts := &NodeListOptions{}
|
||||
|
||||
nodes, _, err := c.Nodes.GetNodes(opts)
|
||||
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, "kgkbpodpt6", opts.StartToken)
|
||||
assert.Equal(t, 2, len(nodes))
|
||||
|
||||
assert.Equal(t, "eRkZ6YMuX5W3VqV3Ia7_lf", *nodes[0].Id)
|
||||
assert.Equal(t, "fooNew.jpg", *nodes[0].Name)
|
||||
|
||||
assert.Equal(t, "fooo1", *nodes[1].Id)
|
||||
assert.Equal(t, "foo.zip", *nodes[1].Name)
|
||||
}
|
||||
|
||||
func TestEscapeForFilter(t *testing.T) {
|
||||
for _, test := range []struct {
|
||||
in string
|
||||
want string
|
||||
}{
|
||||
{"", ""},
|
||||
{"potato", "potato"},
|
||||
{`potato+sausage`, `potato\+sausage`},
|
||||
{`+ - & | ! ( ) { } [ ] ^ ' " ~ * ? : \`, `\+\ \-\ \&\ \|\ \!\ \(\ \)\ \{\ \}\ \[\ \]\ \^\ \'\ \"\ \~\ \*\ \?\ \:\ \\`},
|
||||
} {
|
||||
got := EscapeForFilter(test.in)
|
||||
if test.want != got {
|
||||
t.Errorf("in(%q): want '%s' got '%s'", test.in, test.want, got)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue