Files
athens/pkg/storage/mongo/mongo_test.go
marpio 4785e9c2b3 Remove storage timeouts (#928)
* remove storage timeouts

* fix tests
2018-11-16 16:00:08 -05:00

39 lines
771 B
Go

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_STORAGE_URL")
if url == "" {
tb.SkipNow()
}
backend, err := NewStorage(&config.MongoConfig{URL: url}, config.GetTimeoutDuration(300))
require.NoError(tb, err)
return backend
}