mirror of
https://github.com/gomods/athens
synced 2026-02-03 12:10:32 +00:00
Refactor storage tests (#727)
* Refactor storage tests * minio: check object err * remove inaccurate test * storage/fs: use memory
This commit is contained in:
committed by
Aaron Schlesinger
parent
337488c202
commit
97d8013876
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user