mirror of
https://github.com/gomods/athens
synced 2026-02-03 11:00:32 +00:00
* Changed mongo.go to use new driver * Modified mongo cataloger * More new driver related changes * Change lister.go * Change saver.go * Change imports * Remove unnecessary Count query * Use IndexView for indexing * Rename ModuleStore fields * Use map of key:sorting-order for creating the index * Minor changes * Use client options to configure mongo client * Use method chaining * gofmt changes * Change imports * Fix some build errors * Use new GridFS API * Fix more build errors * Add Go Mongo driver to dependency modules * Use multierror * Leave download stream open * Remove mgo error handling * Copy zip instead of loading all in memory * Use context.WithTimeout() wherever possible * Raise KindNotFound when mod@ver isn't found * NopCloser not needed * Fix IndexView error * Fix build errors * Remove another mgo error usage * Fix build error * Changes according to review * Formatting changes as per gofmt * Modify gofmt argument to show the expected formatting (diff) * Handle ErrNoDocument error and error arising from query execution * Fix kind of returned error * Minor changes * Bug fixes * gofmt related changes * Minor change * Use Insecure from MongoConfig, remove Insecure from global Config * Remove stray print statement
38 lines
782 B
Go
38 lines
782 B
Go
package mongo
|
|
|
|
import (
|
|
"context"
|
|
"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.client.Database(m.db).Drop(context.Background())
|
|
return nil
|
|
}
|
|
|
|
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
|
|
}
|