forked from haramako/cfs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
client_test.go
38 lines (31 loc) · 804 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
package cfs
import (
"testing"
"time"
)
func TestUploadWithFailure(t *testing.T) {
bucket := &Bucket{HashType: "md5", Contents: make(map[string]Content)}
storage, err := NewDummyStorage("")
if err != nil {
t.Errorf("Can't create DummyStorage.")
}
storage.onUpload = func(filename string, hash string, body []byte, overwrite bool) error {
if filename == "error" {
time.Sleep(time.Millisecond * 100) // Wait a while
// return errors.Errorf("error for DummyStorage") // tODO: enable for testing
}
return nil
}
client := &Client{
Bucket: bucket,
Storage: storage,
}
client.Init()
client.AddContent("hoge", []byte("hoge"))
client.AddContent("fuga", []byte("hoge"))
client.AddContent("error", []byte("error"))
err = client.Finish()
if err != nil {
t.Error(err)
}
}