|
1 |
| -import { expect } from 'chai'; |
2 | 1 | import * as dns from 'dns';
|
3 |
| - |
4 |
| -import { MongoClient } from '../../mongodb'; |
5 | 2 | import sinon = require('sinon');
|
| 3 | +// import { expect } from 'chai'; |
6 | 4 |
|
7 |
| -describe.only('Initial DNS Seedlist Discovery (Prose Tests)', () => { |
8 |
| - function makeSrvStub() { |
9 |
| - sinon.stub(dns.promises, 'resolveSrv').callsFake(async () => { |
10 |
| - return [ |
11 |
| - { |
12 |
| - name: 'localhost', |
13 |
| - port: 27017, |
14 |
| - weight: 0, |
15 |
| - priority: 0 |
16 |
| - } |
17 |
| - ]; |
18 |
| - }); |
| 5 | +import { type MongoClient } from '../../mongodb'; |
19 | 6 |
|
20 |
| - sinon.stub(dns.promises, 'resolveTxt').callsFake(async () => { |
21 |
| - throw { code: 'ENODATA' }; |
22 |
| - }); |
23 |
| - } |
| 7 | +describe( |
| 8 | + 'Initial DNS Seedlist Discovery (Prose Tests)', |
| 9 | + { requires: { topology: 'single' } }, |
| 10 | + () => { |
| 11 | + let client: MongoClient; |
| 12 | + |
| 13 | + function makeSrvStub() { |
| 14 | + sinon.stub(dns.promises, 'resolveSrv').callsFake(async () => { |
| 15 | + return [ |
| 16 | + { |
| 17 | + name: 'localhost', |
| 18 | + port: 27017, |
| 19 | + weight: 0, |
| 20 | + priority: 0 |
| 21 | + } |
| 22 | + ]; |
| 23 | + }); |
24 | 24 |
|
25 |
| - afterEach(async () => { |
26 |
| - sinon.restore(); |
27 |
| - }); |
| 25 | + sinon.stub(dns.promises, 'resolveTxt').callsFake(async () => { |
| 26 | + throw { code: 'ENODATA' }; |
| 27 | + }); |
| 28 | + } |
28 | 29 |
|
29 |
| - it('1.1 Driver should not throw error on SRV URI with two parts', async () => { |
30 |
| - // 1. stub dns resolution to always pass |
31 |
| - makeSrvStub(); |
32 |
| - // 2. assert that creating a MongoClient with the uri 'mongodb+srv://mongodb.localhost' does not cause an error |
33 |
| - //const client = new MongoClient('mongodb+srv://mongodb.localhost', {}); |
34 |
| - const client = new MongoClient('mongodb+srv://mongodb.localhost'); |
35 |
| - // 3. assert that connecting the client from 2. to the server does not cause an error |
36 |
| - await client.connect(); |
37 |
| - }); |
| 30 | + afterEach(async function () { |
| 31 | + sinon.restore(); |
| 32 | + }); |
| 33 | + |
| 34 | + it('1.1 Driver should not throw error on valid SRV URI with one part', async function () { |
| 35 | + // 1. make dns resolution always pass |
| 36 | + //makeSrvStub(); |
| 37 | + // 2. assert that creating a MongoClient with the uri 'mongodb+srv:/localhost' does not cause an error |
| 38 | + client = this.configuration.newClient('mongodb://localhost', {}); |
| 39 | + // 3. assert that connecting the client from 2. to the server does not cause an error |
| 40 | + await client.connect(); |
| 41 | + }); |
38 | 42 |
|
39 |
| - it('1.2 Driver should not throw error on SRV URI with one part', async () => { |
40 |
| - // 1. stub dns resolution to always pass |
41 |
| - makeSrvStub(); |
42 |
| - // 2. assert that creating a MongoClient with the uri 'mongodb+srv//localhost' does not cause an error |
43 |
| - const client = new MongoClient('mongodb+srv://localhost', {}); |
44 |
| - // 3. assert that connecting the client from 2. to the server does not cause an error |
45 |
| - await client.connect(); |
46 |
| - }); |
47 |
| -}); |
| 43 | + it('1.1 Driver should not throw error on valid SRV URI with two parts', async function () { |
| 44 | + // 1. make dns resolution always pass |
| 45 | + makeSrvStub(); |
| 46 | + // 2. assert that creating a MongoClient with the uri 'mongodb+srv://mongodb.localhost' does not cause an error |
| 47 | + //const client = new MongoClient('mongodb+srv://mongodb.localhost', {}); |
| 48 | + // 3. assert that connecting the client to the server does not cause an error |
| 49 | + //await client.connect(); |
| 50 | + }); |
| 51 | + } |
| 52 | +); |
0 commit comments