-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathsuperfile_test.go
62 lines (55 loc) · 1.37 KB
/
superfile_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
54
55
56
57
58
59
60
61
62
package bcsgo
import (
// "fmt"
"testing"
"time"
)
var bucketForSuperfileTest *Bucket
func TestSuperfileInit(t *testing.T) {
bucket := createBucketTempForTest(t)
bucketForSuperfileTest = bucket
createTestFile(_TEST_NAME, 256*1024)
}
func TestSuperfilePutAndDelete(t *testing.T) {
bucket := bucketForSuperfileTest
// todo file name with blank char
putFile := func(path, localFile string) *Object {
testObj := bucket.Object(path)
testObj, err := testObj.PutFile(localFile)
if err != nil {
t.Error(err)
}
if testObj.AbsolutePath != path {
t.Error("testObj.AbsolutePath != path", testObj.AbsolutePath, path)
}
return testObj
}
deleteFile := func(testObj *Object) {
deleteErr := testObj.Delete()
if deleteErr != nil {
t.Error(deleteErr)
}
}
dupFileTimes := func(absPath string, obj *Object, times int) *Superfile {
repeats := make([]*Object, 0)
for i := 0; i < times; i++ {
repeats = append(repeats, obj)
}
s := bucket.Superfile(absPath, repeats)
err := s.Put()
if err != nil {
t.Error(err)
}
return s
}
obj := putFile("/testDir/test.txt", _TEST_NAME)
// DEBUG_REQUEST_BODY = true
s := dupFileTimes("/testDir/test.txt", obj, 1024)
deleteFile(&s.Object)
}
func TestSuperfileFinalize(t *testing.T) {
time.Sleep(time.Second)
deleteBucketForTest(t, bucketForSuperfileTest)
bucketForSuperfileTest = nil
deleteTestFile(_TEST_NAME)
}