예제 #1
0
// TestMongoKV tests against a real MongoDB instance, using a Docker container.
func TestMongoKV(t *testing.T) {
	// SetupMongoContainer may skip or fatal the test if docker isn't found or something goes wrong when setting up the container.
	// Thus, no error is returned
	containerID, ip := dockertest.SetupMongoContainer(t)
	defer containerID.KillRemove(t)

	kv, err := sorted.NewKeyValue(jsonconfig.Obj{
		"type":     "mongo",
		"host":     ip,
		"database": "camlitest",
	})
	if err != nil {
		t.Fatalf("mongo.NewKeyValue = %v", err)
	}
	kvtest.TestSorted(t, kv)
}
예제 #2
0
func newMongoSorted(t *testing.T) (kv sorted.KeyValue, cleanup func()) {
	dbname := "camlitest_" + osutil.Username()
	containerID, ip := dockertest.SetupMongoContainer(t)

	kv, err := sorted.NewKeyValue(jsonconfig.Obj{
		"type":     "mongo",
		"host":     ip,
		"database": dbname,
	})
	if err != nil {
		containerID.KillRemove(t)
		t.Fatal(err)
	}
	return kv, func() {
		kv.Close()
		containerID.KillRemove(t)
	}
}
예제 #3
0
// TestMongoStorage tests against a real MongoDB instance, using a Docker container.
// Currently using https://index.docker.io/u/robinvdvleuten/mongo/
func TestMongoStorage(t *testing.T) {
	// SetupMongoContainer may skip or fatal the test if docker isn't found or something goes wrong when setting up the container.
	// Thus, no error is returned
	containerID, ip := dockertest.SetupMongoContainer(t)
	defer containerID.KillRemove(t)

	sto, err := newMongoStorage(config{
		server:     ip,
		database:   "camlitest",
		collection: "blobs",
	})
	if err != nil {
		t.Fatalf("mongo.NewMongoStorage = %v", err)
	}

	storagetest.Test(t, func(t *testing.T) (blobserver.Storage, func()) {
		return sto, func() {}
	})
}