2019-06-11 16:23:20 +00:00
|
|
|
package handler
|
2016-03-11 19:46:34 +00:00
|
|
|
|
|
|
|
import (
|
2019-09-15 11:43:59 +00:00
|
|
|
"context"
|
2016-03-11 19:46:34 +00:00
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
type zeroStore struct{}
|
|
|
|
|
2019-09-15 11:43:59 +00:00
|
|
|
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
|
|
|
}
|
2019-09-15 11:43:59 +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)
|
|
|
|
|
2019-08-20 14:16:05 +00:00
|
|
|
composer := NewStoreComposer()
|
|
|
|
composer.UseCore(zeroStore{})
|
|
|
|
|
2016-03-11 19:46:34 +00:00
|
|
|
config := Config{
|
2019-08-20 14:16:05 +00:00
|
|
|
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())
|
|
|
|
}
|