tusd/pkg/handler/config_test.go

44 lines
739 B
Go
Raw Normal View History

package handler
2016-03-11 19:46:34 +00:00
import (
"testing"
"github.com/stretchr/testify/assert"
)
type zeroStore struct{}
2019-08-24 13:14:51 +00:00
func (store zeroStore) NewUpload(info FileInfo) (Upload, error) {
return nil, nil
2016-03-11 19:46:34 +00:00
}
2019-08-24 13:14:51 +00:00
func (store zeroStore) GetUpload(id string) (Upload, error) {
return nil, nil
2016-03-11 19:46:34 +00:00
}
func TestConfig(t *testing.T) {
a := assert.New(t)
composer := NewStoreComposer()
composer.UseCore(zeroStore{})
2016-03-11 19:46:34 +00:00
config := Config{
StoreComposer: composer,
BasePath: "files",
2016-03-11 19:46:34 +00:00
}
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())
}