Skip to content

Commit badac9d

Browse files
committed
rename and move
1 parent 19be9b1 commit badac9d

File tree

3 files changed

+32
-30
lines changed

3 files changed

+32
-30
lines changed

internal/integration/collection_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"go.mongodb.org/mongo-driver/v2/mongo/options"
2020
"go.mongodb.org/mongo-driver/v2/mongo/writeconcern"
2121
"go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore"
22+
"go.mongodb.org/mongo-driver/v2/x/mongo/driver/integration"
2223
)
2324

2425
const (
@@ -1819,7 +1820,7 @@ func TestCollection(t *testing.T) {
18191820
})
18201821
mt.RunOpts("insert and delete with batches", mtest.NewOptions().ClientType(mtest.Mock), func(mt *mtest.T) {
18211822
// grouped together because delete requires the documents to be inserted
1822-
maxBatchCount := int(mtest.MockDescription.MaxBatchCount)
1823+
maxBatchCount := int(integration.MockDescription.MaxBatchCount)
18231824
numDocs := maxBatchCount + 50
18241825
var insertModels []mongo.WriteModel
18251826
var deleteModels []mongo.WriteModel
@@ -1870,7 +1871,7 @@ func TestCollection(t *testing.T) {
18701871
assert.True(mt, deletes > 1, "expected multiple batches, got %v", deletes)
18711872
})
18721873
mt.RunOpts("update with batches", mtest.NewOptions().ClientType(mtest.Mock), func(mt *mtest.T) {
1873-
maxBatchCount := int(mtest.MockDescription.MaxBatchCount)
1874+
maxBatchCount := int(integration.MockDescription.MaxBatchCount)
18741875
numModels := maxBatchCount + 50
18751876
var models []mongo.WriteModel
18761877

internal/integration/mtest/mongotest.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
"go.mongodb.org/mongo-driver/v2/mongo/writeconcern"
2929
"go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore"
3030
"go.mongodb.org/mongo-driver/v2/x/mongo/driver"
31+
"go.mongodb.org/mongo-driver/v2/x/mongo/driver/integration"
3132
)
3233

3334
var (
@@ -99,7 +100,7 @@ type T struct {
99100
createClient *bool
100101
createCollection *bool
101102
runOn []RunOnBlock
102-
mockDeployment *mockDeployment // nil if the test is not being run against a mock
103+
mockDeployment *integration.MockDeployment // nil if the test is not being run against a mock
103104
mockResponses []bson.D
104105
createdColls []*Collection // collections created in this test
105106
proxyDialer *proxyDialer
@@ -272,12 +273,12 @@ func (t *T) RunOpts(name string, opts *Options, callback func(mt *T)) {
272273
// AddMockResponses adds responses to be returned by the mock deployment. This should only be used if T is being run
273274
// against a mock deployment.
274275
func (t *T) AddMockResponses(responses ...bson.D) {
275-
t.mockDeployment.addResponses(responses...)
276+
t.mockDeployment.AddResponses(responses...)
276277
}
277278

278279
// ClearMockResponses clears all responses in the mock deployment.
279280
func (t *T) ClearMockResponses() {
280-
t.mockDeployment.clearResponses()
281+
t.mockDeployment.ClearResponses()
281282
}
282283

283284
// GetStartedEvent returns the least recent CommandStartedEvent, or nil if one is not present.
@@ -698,7 +699,7 @@ func (t *T) createTestClient() {
698699

699700
args.PoolMonitor = nil
700701

701-
t.mockDeployment = newMockDeployment()
702+
t.mockDeployment = integration.NewMockDeployment()
702703
args.Deployment = t.mockDeployment
703704

704705
opts := mongoutil.NewOptionsLister(args, nil)

internal/integration/mtest/opmsg_deployment.go renamed to x/mongo/driver/integration/opmsg_deployment.go

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// not use this file except in compliance with the License. You may obtain
55
// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
66

7-
package mtest
7+
package integration
88

99
import (
1010
"context"
@@ -122,60 +122,60 @@ func (*connection) Stale() bool {
122122
return false
123123
}
124124

125-
// mockDeployment wraps a connection and implements the driver.Deployment interface.
126-
type mockDeployment struct {
125+
// MockDeployment wraps a connection and implements the driver.Deployment interface.
126+
type MockDeployment struct {
127127
conn *connection
128128
updates chan description.Topology
129129
}
130130

131-
var _ driver.Deployment = &mockDeployment{}
132-
var _ driver.Server = &mockDeployment{}
133-
var _ driver.Connector = &mockDeployment{}
134-
var _ driver.Disconnector = &mockDeployment{}
135-
var _ driver.Subscriber = &mockDeployment{}
131+
var _ driver.Deployment = &MockDeployment{}
132+
var _ driver.Server = &MockDeployment{}
133+
var _ driver.Connector = &MockDeployment{}
134+
var _ driver.Disconnector = &MockDeployment{}
135+
var _ driver.Subscriber = &MockDeployment{}
136136

137137
// SelectServer implements the Deployment interface. This method does not use the
138138
// description.SelectedServer provided and instead returns itself. The Connections returned from the
139139
// Connection method have a no-op Close method.
140-
func (md *mockDeployment) SelectServer(context.Context, description.ServerSelector) (driver.Server, error) {
140+
func (md *MockDeployment) SelectServer(context.Context, description.ServerSelector) (driver.Server, error) {
141141
return md, nil
142142
}
143143

144144
// GetServerSelectionTimeout returns zero as a server selection timeout is not
145145
// applicable for mock deployments.
146-
func (*mockDeployment) GetServerSelectionTimeout() time.Duration {
146+
func (*MockDeployment) GetServerSelectionTimeout() time.Duration {
147147
return 0
148148
}
149149

150150
// Kind implements the Deployment interface. It always returns description.TopologyKindSingle.
151-
func (md *mockDeployment) Kind() description.TopologyKind {
151+
func (md *MockDeployment) Kind() description.TopologyKind {
152152
return description.TopologyKindSingle
153153
}
154154

155155
// Connection implements the driver.Server interface.
156-
func (md *mockDeployment) Connection(context.Context) (*mnet.Connection, error) {
156+
func (md *MockDeployment) Connection(context.Context) (*mnet.Connection, error) {
157157
return mnet.NewConnection(md.conn), nil
158158
}
159159

160160
// RTTMonitor implements the driver.Server interface.
161-
func (md *mockDeployment) RTTMonitor() driver.RTTMonitor {
161+
func (md *MockDeployment) RTTMonitor() driver.RTTMonitor {
162162
return &csot.ZeroRTTMonitor{}
163163
}
164164

165165
// Connect is a no-op method which implements the driver.Connector interface.
166-
func (md *mockDeployment) Connect() error {
166+
func (md *MockDeployment) Connect() error {
167167
return nil
168168
}
169169

170170
// Disconnect is a no-op method which implements the driver.Disconnector interface {
171-
func (md *mockDeployment) Disconnect(context.Context) error {
171+
func (md *MockDeployment) Disconnect(context.Context) error {
172172
close(md.updates)
173173
return nil
174174
}
175175

176176
// Subscribe returns a subscription from which new topology descriptions can be retrieved.
177177
// Subscribe implements the driver.Subscriber interface.
178-
func (md *mockDeployment) Subscribe() (*driver.Subscription, error) {
178+
func (md *MockDeployment) Subscribe() (*driver.Subscription, error) {
179179
if md.updates == nil {
180180
md.updates = make(chan description.Topology, 1)
181181

@@ -190,23 +190,23 @@ func (md *mockDeployment) Subscribe() (*driver.Subscription, error) {
190190
}
191191

192192
// Unsubscribe is a no-op method which implements the driver.Subscriber interface.
193-
func (md *mockDeployment) Unsubscribe(*driver.Subscription) error {
193+
func (md *MockDeployment) Unsubscribe(*driver.Subscription) error {
194194
return nil
195195
}
196196

197-
// addResponses adds responses to this mock deployment.
198-
func (md *mockDeployment) addResponses(responses ...bson.D) {
197+
// AddResponses adds responses to this mock deployment.
198+
func (md *MockDeployment) AddResponses(responses ...bson.D) {
199199
md.conn.responses = append(md.conn.responses, responses...)
200200
}
201201

202-
// clearResponses clears all remaining responses in this mock deployment.
203-
func (md *mockDeployment) clearResponses() {
202+
// ClearResponses clears all remaining responses in this mock deployment.
203+
func (md *MockDeployment) ClearResponses() {
204204
md.conn.responses = md.conn.responses[:0]
205205
}
206206

207-
// newMockDeployment returns a mock driver.Deployment that responds with OP_MSG wire messages.
208-
func newMockDeployment(responses ...bson.D) *mockDeployment {
209-
return &mockDeployment{
207+
// NewMockDeployment returns a mock driver.Deployment that responds with OP_MSG wire messages.
208+
func NewMockDeployment(responses ...bson.D) *MockDeployment {
209+
return &MockDeployment{
210210
conn: &connection{
211211
responses: responses,
212212
},

0 commit comments

Comments
 (0)