Skip to content

Commit e024ec6

Browse files
committed
test: stub only resolve
1 parent 4e89a87 commit e024ec6

4 files changed

Lines changed: 21 additions & 21 deletions

File tree

test/integration/initial-dns-seedlist-discovery/initial_dns_seedlist_discovery.prose.test.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ describe('Initial DNS Seedlist Discovery (Prose Tests)', () => {
3434
];
3535
});
3636

37-
sinon.stub(dns.promises, 'resolveTxt').callsFake(async () => {
37+
sinon.stub(dns.promises, 'resolve').callsFake(async () => {
3838
throw { code: 'ENODATA' };
3939
});
4040

@@ -86,7 +86,7 @@ describe('Initial DNS Seedlist Discovery (Prose Tests)', () => {
8686
*/
8787

8888
beforeEach(async function () {
89-
sinon.stub(dns.promises, 'resolveTxt').callsFake(async () => {
89+
sinon.stub(dns.promises, 'resolve').callsFake(async () => {
9090
throw { code: 'ENODATA' };
9191
});
9292
});
@@ -96,7 +96,7 @@ describe('Initial DNS Seedlist Discovery (Prose Tests)', () => {
9696
});
9797

9898
it('an SRV with one domain level causes a runtime error', async function () {
99-
sinon.stub(dns.promises, 'resolveSrv').callsFake(async () => {
99+
sinon.stub(dns.promises, 'resolve').callsFake(async () => {
100100
return [
101101
{
102102
name: 'localhost.mongodb',
@@ -115,7 +115,7 @@ describe('Initial DNS Seedlist Discovery (Prose Tests)', () => {
115115
});
116116

117117
it('an SRV with two domain levels causes a runtime error', async function () {
118-
sinon.stub(dns.promises, 'resolveSrv').callsFake(async () => {
118+
sinon.stub(dns.promises, 'resolve').callsFake(async () => {
119119
return [
120120
{
121121
name: 'test_1.evil.local', // this string only ends with part of the domain, not all of it!
@@ -134,7 +134,7 @@ describe('Initial DNS Seedlist Discovery (Prose Tests)', () => {
134134
});
135135

136136
it('an SRV with three or more domain levels causes a runtime error', async function () {
137-
sinon.stub(dns.promises, 'resolveSrv').callsFake(async () => {
137+
sinon.stub(dns.promises, 'resolve').callsFake(async () => {
138138
return [
139139
{
140140
name: 'blogs.evil.com',
@@ -167,7 +167,7 @@ describe('Initial DNS Seedlist Discovery (Prose Tests)', () => {
167167
'when given a host from DNS resolution that is identical to the original SRVs hostname',
168168
function () {
169169
beforeEach(async function () {
170-
sinon.stub(dns.promises, 'resolveTxt').callsFake(async () => {
170+
sinon.stub(dns.promises, 'resolve').callsFake(async () => {
171171
throw { code: 'ENODATA' };
172172
});
173173
});
@@ -177,7 +177,7 @@ describe('Initial DNS Seedlist Discovery (Prose Tests)', () => {
177177
});
178178

179179
it('an SRV with one domain level causes a runtime error', async function () {
180-
sinon.stub(dns.promises, 'resolveSrv').callsFake(async () => {
180+
sinon.stub(dns.promises, 'resolve').callsFake(async () => {
181181
return [
182182
{
183183
name: 'localhost',
@@ -198,7 +198,7 @@ describe('Initial DNS Seedlist Discovery (Prose Tests)', () => {
198198
});
199199

200200
it('an SRV with two domain levels causes a runtime error', async function () {
201-
sinon.stub(dns.promises, 'resolveSrv').callsFake(async () => {
201+
sinon.stub(dns.promises, 'resolve').callsFake(async () => {
202202
return [
203203
{
204204
name: 'mongo.local',
@@ -234,7 +234,7 @@ describe('Initial DNS Seedlist Discovery (Prose Tests)', () => {
234234
'when given a returned address that does NOT share the domain name of the SRV record because its missing a `.`',
235235
function () {
236236
beforeEach(async function () {
237-
sinon.stub(dns.promises, 'resolveTxt').callsFake(async () => {
237+
sinon.stub(dns.promises, 'resolve').callsFake(async () => {
238238
throw { code: 'ENODATA' };
239239
});
240240
});
@@ -244,7 +244,7 @@ describe('Initial DNS Seedlist Discovery (Prose Tests)', () => {
244244
});
245245

246246
it('an SRV with one domain level causes a runtime error', async function () {
247-
sinon.stub(dns.promises, 'resolveSrv').callsFake(async () => {
247+
sinon.stub(dns.promises, 'resolve').callsFake(async () => {
248248
return [
249249
{
250250
name: 'test_1.cluster_1localhost',
@@ -263,7 +263,7 @@ describe('Initial DNS Seedlist Discovery (Prose Tests)', () => {
263263
});
264264

265265
it('an SRV with two domain levels causes a runtime error', async function () {
266-
sinon.stub(dns.promises, 'resolveSrv').callsFake(async () => {
266+
sinon.stub(dns.promises, 'resolve').callsFake(async () => {
267267
return [
268268
{
269269
name: 'test_1.my_hostmongo.local',
@@ -282,7 +282,7 @@ describe('Initial DNS Seedlist Discovery (Prose Tests)', () => {
282282
});
283283

284284
it('an SRV with three domain levels causes a runtime error', async function () {
285-
sinon.stub(dns.promises, 'resolveSrv').callsFake(async () => {
285+
sinon.stub(dns.promises, 'resolve').callsFake(async () => {
286286
return [
287287
{
288288
name: 'cluster.testmongodb.com',

test/unit/assorted/polling_srv_records_for_mongos_discovery.prose.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ describe('Polling Srv Records for Mongos Discovery', () => {
282282
initialRecords ??= mockRecords;
283283
// first call is for the driver initial connection
284284
// second call will check the poller
285-
resolveSrvStub = sinon.stub(dns.promises, 'resolveSrv').callsFake(async address => {
285+
resolveSrvStub = sinon.stub(dns.promises, 'resolve').callsFake(async address => {
286286
expect(address).to.equal(`_${srvServiceName}._tcp.test.mock.test.build.10gen.cc`);
287287
if (initialDNSLookup) {
288288
initialDNSLookup = false;

test/unit/connection_string.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -631,13 +631,13 @@ describe('Connection String', function () {
631631

632632
const mockRecord: string[][] = [[txtRecord]];
633633

634-
// first call is for stubbing resolveSrv
635-
// second call is for stubbing resolveTxt
636-
sinon.stub(dns.promises, 'resolveSrv').callsFake(async () => {
634+
// first call is for stubbing resolve
635+
// second call is for stubbing resolve
636+
sinon.stub(dns.promises, 'resolve').callsFake(async () => {
637637
return mockAddress;
638638
});
639639

640-
sinon.stub(dns.promises, 'resolveTxt').callsFake(async () => {
640+
sinon.stub(dns.promises, 'resolve').callsFake(async () => {
641641
return mockRecord;
642642
});
643643
}

test/unit/sdam/srv_polling.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ describe('Mongos SRV Polling', function () {
2828

2929
function stubDns(err: Error | null, records?: dns.SrvRecord[]) {
3030
if (err) {
31-
sinon.stub(dns.promises, 'resolveSrv').rejects(err);
31+
sinon.stub(dns.promises, 'resolve').rejects(err);
3232
} else {
33-
sinon.stub(dns.promises, 'resolveSrv').resolves(records);
33+
sinon.stub(dns.promises, 'resolve').resolves(records);
3434
}
3535
}
3636

@@ -93,13 +93,13 @@ describe('Mongos SRV Polling', function () {
9393
it('should poll dns srv records', async function () {
9494
const poller = new SrvPoller({ srvHost: SRV_HOST });
9595

96-
sinon.stub(dns.promises, 'resolveSrv').resolves([srvRecord('iLoveJavascript.lots')]);
96+
sinon.stub(dns.promises, 'resolve').resolves([srvRecord('iLoveJavascript.lots')]);
9797

9898
await poller._poll();
9999

100100
clearTimeout(poller._timeout);
101101

102-
expect(dns.promises.resolveSrv).to.have.been.calledOnce.and.to.have.been.calledWith(
102+
expect(dns.promises.resolve).to.have.been.calledOnce.and.to.have.been.calledWith(
103103
`_mongodb._tcp.${SRV_HOST}`
104104
);
105105
});

0 commit comments

Comments
 (0)