Catalog endpoint support for mongo (#985)

* Added new cataloger interface

* Implementing catalog protocol

* Propagated to protocol and over

* First round of fixes

* S3 almost ready, need to be tested

* Going on with testing s3

* Better testing with s3

* Simplified catalog tests

* Preparing gcp tests to access a gcp instance

* Fixing initialization errors

* Removed some prints

* Gcp ready, to be tested

* Gcp working

* Aligned bucket mock to catalog method

* Switched res payload to json

* Added catalog method to all storage instances

* Added catalog method to unsupported storages

* Fixed with pool test

* Restored tests

* Fixed gcp constructor

* Implemented catalog for fs

* Removed trace

* E2e tests, fixed fs

* Fixed module name return value

* Added cataloger method to azure storage

* Added docs

* Changed pagesize parameter name

* Fixed gofmt error

* Added json tags to result. Fixed lint warning

* Removed extra line

* Changed not implemented error to http.KindNotImplemented

* Checking for inequality on results

* Lower-cased json keys

* Added cleaning of path separator

* Fixed review comments

* Add catalog endpoint for mongo

* Add omitempty to ID

* Fix catalog tests

* update for next token

* fix e2e

* Make query readable

* Fix language and e2e script

* remove new line
This commit is contained in:
Manu Gupta
2019-01-02 22:13:56 -08:00
committed by GitHub
parent 3b621caa85
commit 23b285d49d
7 changed files with 66 additions and 22 deletions
+12 -6
View File
@@ -1,7 +1,7 @@
package mongo
import (
"os"
"path/filepath"
"testing"
"github.com/gomods/athens/pkg/config"
@@ -9,14 +9,17 @@ 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)
}
func (m *ModuleStore) clear() error {
m.s.DB(m.d).C(m.c).DropCollection()
m.s.DB(m.d).DropDatabase()
return m.initDatabase()
}
@@ -26,12 +29,15 @@ func BenchmarkBackend(b *testing.B) {
}
func getStorage(tb testing.TB) *ModuleStore {
url := os.Getenv("ATHENS_MONGO_STORAGE_URL")
if url == "" {
conf, err := config.GetConf(testConfigFile)
if err != nil {
tb.Fatalf("Unable to parse config file: %s", err.Error())
}
if conf.Storage.Mongo.URL == "" {
tb.SkipNow()
}
backend, err := NewStorage(&config.MongoConfig{URL: url}, config.GetTimeoutDuration(300))
backend, err := NewStorage(&config.MongoConfig{URL: conf.Storage.Mongo.URL}, config.GetTimeoutDuration(300))
require.NoError(tb, err)
return backend