tusd/pkg/handler/config_test.go

45 lines
792 B
Go
Raw Normal View History

package handler
2016-03-11 19:46:34 +00:00
import (
"context"
2016-03-11 19:46:34 +00:00
"testing"
"github.com/stretchr/testify/assert"
)
type zeroStore struct{}
func (store zeroStore) NewUpload(ctx context.Context, info FileInfo) (Upload, error) {
2019-08-24 13:14:51 +00:00
return nil, nil
2016-03-11 19:46:34 +00:00
}
func (store zeroStore) GetUpload(ctx context.Context, id string) (Upload, error) {
2019-08-24 13:14:51 +00:00
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())
}