@@ -15,6 +15,7 @@ import (
15
15
"go.mongodb.org/mongo-driver/mongo/description"
16
16
"go.mongodb.org/mongo-driver/x/bsonx/bsoncore"
17
17
"go.mongodb.org/mongo-driver/x/mongo/driver"
18
+ "go.mongodb.org/mongo-driver/x/mongo/driver/topology"
18
19
"go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage"
19
20
)
20
21
@@ -24,7 +25,22 @@ const (
24
25
maxMessageSize uint32 = 48000000
25
26
maxBatchCount uint32 = 100000
26
27
sessionTimeoutMinutes uint32 = 30
27
- maxWireVersion int32 = 8
28
+ )
29
+
30
+ var (
31
+ // MockDescription is the server description used for the mock deployment. Each mocked connection returns this
32
+ // value from its Description method.
33
+ MockDescription = description.Server {
34
+ CanonicalAddr : serverAddress ,
35
+ MaxDocumentSize : maxDocumentSize ,
36
+ MaxMessageSize : maxMessageSize ,
37
+ MaxBatchCount : maxBatchCount ,
38
+ SessionTimeoutMinutes : sessionTimeoutMinutes ,
39
+ Kind : description .RSPrimary ,
40
+ WireVersion : & description.VersionRange {
41
+ Max : topology .SupportedWireVersions .Max ,
42
+ },
43
+ }
28
44
)
29
45
30
46
// connection implements the driver.Connection interface and responds to wire messages with pre-configured responses.
@@ -59,17 +75,7 @@ func (c *connection) ReadWireMessage(_ context.Context, dst []byte) ([]byte, err
59
75
60
76
// Description returns a fixed server description for the connection.
61
77
func (c * connection ) Description () description.Server {
62
- return description.Server {
63
- CanonicalAddr : serverAddress ,
64
- MaxDocumentSize : maxDocumentSize ,
65
- MaxMessageSize : maxMessageSize ,
66
- MaxBatchCount : maxBatchCount ,
67
- SessionTimeoutMinutes : sessionTimeoutMinutes ,
68
- Kind : description .RSPrimary ,
69
- WireVersion : & description.VersionRange {
70
- Max : maxWireVersion ,
71
- },
72
- }
78
+ return MockDescription
73
79
}
74
80
75
81
// Close is a no-op operation.
0 commit comments