mongo: use explicit URL for testing (#1025)

This commit is contained in:
Marwan Sulaiman
2019-01-04 14:23:49 -05:00
committed by marpio
parent 23b285d49d
commit 2bd4c9d12f
+4 -12
View File
@@ -1,7 +1,7 @@
package mongo
import (
"path/filepath"
"os"
"testing"
"github.com/gomods/athens/pkg/config"
@@ -9,10 +9,6 @@ import (
"github.com/stretchr/testify/require"
)
var (
testConfigFile = filepath.Join("..", "..", "..", "config.dev.toml")
)
func TestBackend(t *testing.T) {
backend := getStorage(t)
compliance.RunTests(t, backend, backend.clear)
@@ -29,15 +25,11 @@ func BenchmarkBackend(b *testing.B) {
}
func getStorage(tb testing.TB) *ModuleStore {
conf, err := config.GetConf(testConfigFile)
if err != nil {
tb.Fatalf("Unable to parse config file: %s", err.Error())
}
if conf.Storage.Mongo.URL == "" {
url := os.Getenv("ATHENS_MONGO_STORAGE_URL")
if url == "" {
tb.SkipNow()
}
backend, err := NewStorage(&config.MongoConfig{URL: conf.Storage.Mongo.URL}, config.GetTimeoutDuration(300))
backend, err := NewStorage(&config.MongoConfig{URL: url}, config.GetTimeoutDuration(300))
require.NoError(tb, err)
return backend