mirror of
https://github.com/gomods/athens
synced 2026-02-03 11:00:32 +00:00
* 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
52 lines
1.0 KiB
Go
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)
|
|
}
|