Skip to content

Commit c6a042b

Browse files
committed
Add parametrized test-cases.
1 parent 5ce8b92 commit c6a042b

File tree

1 file changed

+55
-16
lines changed

1 file changed

+55
-16
lines changed

source/mongodb-handshake/tests/README.md

Lines changed: 55 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@ for verification purposes.
9494
Drivers should verify that metadata provided after `MongoClient` initialization is appended, not replaced, and is
9595
visible in the `hello` command of new connections.
9696

97+
There are multiple test cases parameterized with `DriverInfoOptions` to be appended after `MongoClient` initialization.
98+
Before each test case, perform the setup.
99+
100+
#### Setup
101+
97102
1. Create a `MongoClient` instance with the following:
98103

99104
- `maxIdleTimeMS` set to `1ms`
@@ -114,33 +119,67 @@ visible in the `hello` command of new connections.
114119

115120
3. Wait 5ms for the connection to become idle.
116121

117-
4. Append the following `DriverInfoOptions` to the `MongoClient` metadata:
122+
#### Parameterized test cases
118123

119-
| Field | Value |
120-
| -------- | ------------------ |
121-
| name | framework |
122-
| version | 2.0 |
123-
| platform | Framework Platform |
124+
**Case 1**
125+
126+
| Field | Value |
127+
| -------- | ------------------ |
128+
| name | framework |
129+
| version | 2.0 |
130+
| platform | Framework Platform |
131+
132+
**Case 2**
124133

125-
5. Send `ping` command to the server and verify:
134+
| Field | Value |
135+
| -------- | --------- |
136+
| name | framework |
137+
| version | 2.0 |
138+
| platform | null |
139+
140+
**Case 3**
141+
142+
| Field | Value |
143+
| -------- | ------------------ |
144+
| name | framework |
145+
| version | null |
146+
| platform | Framework Platform |
147+
148+
**Case 4**
149+
150+
| Field | Value |
151+
| -------- | --------- |
152+
| name | framework |
153+
| version | null |
154+
| platform | null |
155+
156+
#### Running a test case
157+
158+
1. Append the `DriverInfoOptions` from the selected test case to the `MongoClient` metadata.
159+
160+
2. Send a `ping` command to the server and verify:
126161

127162
- The command succeeds.
128163

129164
- The framework metadata is appended to the existing `DriverInfoOptions` in the `client.driver` fields of the `hello`
130-
command.
165+
command, with values separated by a pipe `|`.
131166

132-
| Field | Value |
133-
| -------- | ------------------------------------ |
134-
| name | library\|framework |
135-
| version | 1.2\|2.0 |
136-
| platform | Library Platform\|Framework Platform |
167+
- `client.driver.name`:
168+
- If test case's name is non-null: `library|<name>`
169+
- Otherwise, the field remains unchanged: `library`
170+
- `client.driver.version`:
171+
- If test case's version is non-null: `1.2|<version>`
172+
- Otherwise, the field remains unchanged: `1.2`
173+
- `client.driver.platform`:
174+
- If test case's platform is non-null: `Library Platform|<platform>`
175+
- Otherwise, the field remains unchanged: `Library Platform`
137176

138-
- All other subfields in the client document remain unchanged from `initialClientMetadata`.
177+
- All other subfields in the `client` document remain unchanged from `initialClientMetadata`.
139178

140179
### Test 2: Test that metadata is not updated on established connections
141180

142181
Drivers should verify that appending metadata after `MongoClient` initialization does **not** close existing
143-
connections, and that no new `hello` command is sent.
182+
connections, and that no new `hello` command is sent on existing connections.
144183

145184
1. Create a `MongoClient` instance with wrapping library metadata:
146185

@@ -163,7 +202,7 @@ connections, and that no new `hello` command is sent.
163202
| version | 2.0 |
164203
| platform | Framework Platform |
165204

166-
4. Send another `ping` command to the server and verify:
205+
4. Send a `ping` command to the server and verify:
167206

168207
- The command succeeds.
169208
- No `hello` command is sent.

0 commit comments

Comments
 (0)