-
Notifications
You must be signed in to change notification settings - Fork 21
/
export_test.go
37 lines (30 loc) · 981 Bytes
/
export_test.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 2016 Canonical Ltd.
// Licensed under the LGPLv3, see LICENCE file for details.
package txn
import (
"time"
"github.com/juju/mgo/v3"
)
type TxnRunner txnRunner
// Specify the function that creates the txnRunner for testing.
func SetRunnerFunc(r Runner, f func() TxnRunner) {
inner := r.(*transactionRunner)
inner.newRunner = func() txnRunner {
return f()
}
}
var CheckMongoSupportsOut = checkMongoSupportsOut
// NewDBOracleNoOut is only used for testing. It forces the DBOracle to not ask
// mongo to populate the working set in the aggregation pipeline, which is our
// compatibility code for older mongo versions.
func NewDBOracleNoOut(txns *mgo.Collection, thresholdTime time.Time, maxTxns int) (*DBOracle, func(), error) {
oracle := &DBOracle{
db: txns.Database,
txns: txns,
maxTxns: maxTxns,
usingMongoOut: false,
thresholdTime: thresholdTime,
}
cleanup, err := oracle.prepare()
return oracle, cleanup, err
}