Refactor storage tests (#727)

* Refactor storage tests

* minio: check object err

* remove inaccurate test

* storage/fs: use memory
This commit is contained in:
Marwan Sulaiman
2018-10-04 19:16:24 -04:00
committed by Aaron Schlesinger
parent 337488c202
commit 97d8013876
20 changed files with 378 additions and 752 deletions
+38
View File
@@ -0,0 +1,38 @@
package mongo
import (
"os"
"testing"
"github.com/gomods/athens/pkg/config"
"github.com/gomods/athens/pkg/storage/compliance"
"github.com/stretchr/testify/require"
)
func TestBackend(t *testing.T) {
backend := getStorage(t)
compliance.RunTests(t, backend, backend.clear)
}
func (m *ModuleStore) clear() error {
m.s.DB(m.d).C(m.c).DropCollection()
return m.initDatabase()
}
func BenchmarkBackend(b *testing.B) {
backend := getStorage(b)
compliance.RunBenchmarks(b, backend, backend.clear)
}
func getStorage(tb testing.TB) *ModuleStore {
url := os.Getenv("ATHENS_MONGO_URL")
if url == "" {
tb.SkipNow()
}
backend, err := NewStorage(&config.MongoConfig{URL: url})
require.NoError(tb, err)
return backend
}