mirror of
https://github.com/gomods/athens
synced 2026-02-03 11:00:32 +00:00
mongo: use explicit URL for testing (#1025)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user