-
Notifications
You must be signed in to change notification settings - Fork 0
/
config_test.go
58 lines (44 loc) · 1.01 KB
/
config_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
package tusd
import (
"io"
"testing"
"github.com/stretchr/testify/assert"
)
type zeroStore struct{}
func (store zeroStore) NewUpload(info FileInfo) (string, error) {
return "", nil
}
func (store zeroStore) WriteChunk(id string, offset int64, src io.Reader) (int64, error) {
return 0, nil
}
func (store zeroStore) GetInfo(id string) (FileInfo, error) {
return FileInfo{}, nil
}
func TestConfig(t *testing.T) {
a := assert.New(t)
config := Config{
DataStore: zeroStore{},
BasePath: "files",
}
a.Nil(config.validate())
a.NotNil(config.Logger)
a.NotNil(config.StoreComposer)
a.Equal("/files/", config.BasePath)
}
func TestConfigEmptyCore(t *testing.T) {
a := assert.New(t)
config := Config{
StoreComposer: NewStoreComposer(),
}
a.Error(config.validate())
}
func TestConfigStoreAndComposer(t *testing.T) {
a := assert.New(t)
composer := NewStoreComposer()
composer.UseCore(zeroStore{})
config := Config{
StoreComposer: composer,
DataStore: zeroStore{},
}
a.Error(config.validate())
}