-
Notifications
You must be signed in to change notification settings - Fork 0
/
mgo.go
37 lines (32 loc) · 1.35 KB
/
mgo.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Copyright 2012, 2013 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.
package testing
import (
"testing"
"time"
mgotesting "github.com/juju/mgo/v3/testing"
)
// MgoTestPackage should be called to register the tests for any package
// that requires a connection to a MongoDB server.
//
// The server will be configured without SSL enabled, which slows down
// tests. For tests that care about security (which should be few), use
// MgoSSLTestPackage.
func MgoTestPackage(t *testing.T) {
mgotesting.MgoServer.EnableReplicaSet = true
// Tests tend to cause enough contention that the default lock request
// timeout of 5ms is not enough. We may need to consider increasing the
// value for production also.
mgotesting.MgoServer.MaxTransactionLockRequestTimeout = 20 * time.Millisecond
mgotesting.MgoTestPackage(t, nil)
}
// MgoSSLTestPackage should be called to register the tests for any package
// that requires a secure (SSL) connection to a MongoDB server.
func MgoSSLTestPackage(t *testing.T) {
mgotesting.MgoServer.EnableReplicaSet = true
// Tests tend to cause enough contention that the default lock request
// timeout of 5ms is not enough. We may need to consider increasing the
// value for production also.
mgotesting.MgoServer.MaxTransactionLockRequestTimeout = 20 * time.Millisecond
mgotesting.MgoTestPackage(t, Certs)
}