Files
athens/pkg/storage/fs/test_suite.go
marpio 29b6b6ffab Minio conf + tests refactoring (#680)
* cleanup tests and change minio port

* fix cleanup

* cleanup

* fix config test

* add comment to travis

* revert to generic minio addr

* fix test

* switch to test config

* adapt timeouts

* use example config

* fix test... again

* add new lines
2018-09-20 21:31:21 +02:00

52 lines
1.0 KiB
Go

package fs
import (
"github.com/gobuffalo/suite"
"github.com/gomods/athens/pkg/storage"
"github.com/spf13/afero"
)
// TestSuite implements storage.TestSuite interface
type TestSuite struct {
*suite.Model
storage storage.Backend
fs afero.Fs
rootDir string
}
// NewTestSuite creates a common test suite
func NewTestSuite(model *suite.Model) (storage.TestSuite, error) {
osFs := afero.NewOsFs()
r, err := afero.TempDir(osFs, "", "athens-fs-storage-tests")
if err != nil {
return nil, err
}
fsStore, err := NewStorage(r, osFs)
if err != nil {
return nil, err
}
return &TestSuite{
Model: model,
fs: osFs,
rootDir: r,
storage: fsStore,
}, nil
}
// Storage retrieves initialized storage backend
func (ts *TestSuite) Storage() storage.Backend {
return ts.storage
}
// StorageHumanReadableName retrieves readable identifier of the storage
func (ts *TestSuite) StorageHumanReadableName() string {
return "FileSystem"
}
// Cleanup tears down test
func (ts *TestSuite) Cleanup() error {
return ts.fs.RemoveAll(ts.rootDir)
}