Skip to content

Commit 8575558

Browse files
renovate[bot]JustinBeckwith
authored andcommitted
chore(deps): update dependency @types/sinon to v7.0.9 (#553)
1 parent 1cf52d7 commit 8575558

File tree

4 files changed

+56
-42
lines changed

4 files changed

+56
-42
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
"@types/mocha": "^5.2.5",
8888
"@types/p-retry": "^3.0.0",
8989
"@types/proxyquire": "^1.3.28",
90-
"@types/sinon": "7.0.8",
90+
"@types/sinon": "^7.0.9",
9191
"@types/stack-trace": "0.0.29",
9292
"@types/through2": "^2.0.34",
9393
"@types/time-span": "^2.0.0",

test/database.ts

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import {util} from '@google-cloud/common-grpc';
2828
import * as pfy from '@google-cloud/promisify';
2929
import * as db from '../src/database';
3030
import {Instance} from '../src';
31+
import {TimestampBounds} from '../src/transaction';
3132

3233
let promisified = false;
3334
const fakePfy = extend({}, pfy, {
@@ -1256,9 +1257,9 @@ describe('Database', () => {
12561257
let fakeSnapshot: FakeTransaction;
12571258
let fakeStream: Transform;
12581259

1259-
let getReadSessionStub: sinon.SinonStub;
1260-
let snapshotStub: sinon.SinonStub;
1261-
let runStreamStub: sinon.SinonStub;
1260+
let getReadSessionStub: sinon.SinonStub<[ReadSessionCallback], void>;
1261+
let snapshotStub: sinon.SinonStub<[TimestampBounds?], FakeTransaction>;
1262+
let runStreamStub: sinon.SinonStub<[string|{}], Transform>;
12621263

12631264
beforeEach(() => {
12641265
fakePool = database.pool_;
@@ -1521,9 +1522,9 @@ describe('Database', () => {
15211522
let fakeSession: FakeSession;
15221523
let fakeSnapshot: FakeTransaction;
15231524

1524-
let beginSnapshotStub: sinon.SinonStub;
1525-
let getReadSessionStub: sinon.SinonStub;
1526-
let snapshotStub: sinon.SinonStub;
1525+
let beginSnapshotStub: sinon.SinonStub<[Function], void>;
1526+
let getReadSessionStub: sinon.SinonStub<[ReadSessionCallback], void>;
1527+
let snapshotStub: sinon.SinonStub<[TimestampBounds?], FakeTransaction>;
15271528

15281529
beforeEach(() => {
15291530
fakePool = database.pool_;
@@ -1618,7 +1619,7 @@ describe('Database', () => {
16181619
let fakeSession: FakeSession;
16191620
let fakeTransaction: FakeTransaction;
16201621

1621-
let getWriteSessionStub: sinon.SinonStub;
1622+
let getWriteSessionStub: sinon.SinonStub<[WriteSessionCallback], void>;
16221623

16231624
beforeEach(() => {
16241625
fakePool = database.pool_;
@@ -1750,10 +1751,10 @@ describe('Database', () => {
17501751
let fakeSession: FakeSession;
17511752
let fakePartitionedDml: FakeTransaction;
17521753

1753-
let getReadSessionStub: sinon.SinonStub;
1754-
let partitionedDmlStub: sinon.SinonStub;
1755-
let beginStub: sinon.SinonStub;
1756-
let runUpdateStub: sinon.SinonStub;
1754+
let getReadSessionStub: sinon.SinonStub<[ReadSessionCallback], void>;
1755+
let partitionedDmlStub: sinon.SinonStub<[], FakeTransaction>;
1756+
let beginStub: sinon.SinonStub<[Function], void>;
1757+
let runUpdateStub: sinon.SinonStub<[string|{}, Function], void>;
17571758

17581759
beforeEach(() => {
17591760
fakePool = database.pool_;

test/session-pool.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ describe('SessionPool', () => {
442442
});
443443

444444
describe('open', () => {
445-
let fillStub: sinon.SinonStub;
445+
let fillStub: sinon.SinonStub<[], Promise<void>>;
446446

447447
beforeEach(() => {
448448
sessionPool._stopHouseKeeping = sandbox.stub();
@@ -479,7 +479,7 @@ describe('SessionPool', () => {
479479
});
480480

481481
describe('release', () => {
482-
let prepStub: sinon.SinonStub;
482+
let prepStub: sinon.SinonStub<[Session], Promise<void>>;
483483

484484
beforeEach(() => {
485485
prepStub = sandbox.stub(sessionPool, '_prepareTransaction').resolves();
@@ -880,7 +880,7 @@ describe('SessionPool', () => {
880880
});
881881

882882
describe('_evictIdleSessions', () => {
883-
let destroyStub: sinon.SinonStub;
883+
let destroyStub: sinon.SinonStub<[Session], Promise<void>>;
884884
let fakeSessions;
885885

886886
beforeEach(() => {
@@ -939,8 +939,8 @@ describe('SessionPool', () => {
939939
});
940940

941941
describe('_fill', () => {
942-
let readonly: sinon.SinonStub;
943-
let readwrite: sinon.SinonStub;
942+
let readonly: sinon.SinonStub<[types], Promise<void>>;
943+
let readwrite: sinon.SinonStub<[types], Promise<void>>;
944944

945945
beforeEach(() => {
946946
const stub = sandbox.stub(sessionPool, '_createSessionInBackground');
@@ -983,7 +983,7 @@ describe('SessionPool', () => {
983983
const end = timeSpan();
984984

985985
const delayedResolve = () =>
986-
new Promise(resolve => setTimeout(resolve, delay));
986+
new Promise<void>(resolve => setTimeout(resolve, delay));
987987

988988
readonly.callsFake(delayedResolve);
989989
readwrite.callsFake(delayedResolve);

test/table.ts

Lines changed: 37 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ import {split} from 'split-array-stream';
2424
import {Transform} from 'stream';
2525
import * as through from 'through2';
2626

27+
import {TimestampBounds} from '../src/transaction';
28+
2729
let promisified = false;
2830
const fakePfy = extend({}, pfy, {
2931
promisifyAll(klass, options) {
@@ -35,6 +37,26 @@ const fakePfy = extend({}, pfy, {
3537
},
3638
});
3739

40+
class FakeTransaction {
41+
commit(callback) {
42+
callback(null, {});
43+
}
44+
createReadStream() {
45+
return through.obj();
46+
}
47+
deleteRows(name, keys) {}
48+
end() {}
49+
insert(table, row) {}
50+
replace(table, row) {}
51+
upsert(table, row) {}
52+
update(table, row) {}
53+
}
54+
55+
interface GetSnapshotCallback {
56+
(err: Error, snapshot?: null): void;
57+
(err: null, snapshot: FakeTransaction): void;
58+
}
59+
3860
describe('Table', () => {
3961
const sandbox = sinon.createSandbox();
4062

@@ -43,21 +65,11 @@ describe('Table', () => {
4365
// tslint:disable-next-line no-any variable-name
4466
let TableCached: any;
4567
let table;
68+
let transaction: FakeTransaction;
4669

4770
const DATABASE = {
48-
runTransaction: callback => callback(null, TRANSACTION),
49-
getSnapshot: (options, callback) => callback(null, TRANSACTION),
50-
};
51-
52-
const TRANSACTION = {
53-
commit: callback => callback(),
54-
createReadStream: () => through.obj(),
55-
deleteRows: (name, keys) => {},
56-
end: () => {},
57-
insert: (table, row) => {},
58-
replace: (table, row) => {},
59-
upsert: (table, row) => {},
60-
update: (table, row) => {},
71+
runTransaction: callback => callback(null, transaction),
72+
getSnapshot: (options, callback) => callback(null, transaction),
6173
};
6274

6375
const NAME = 'table-name';
@@ -72,6 +84,7 @@ describe('Table', () => {
7284
beforeEach(() => {
7385
extend(Table, TableCached);
7486
table = new Table(DATABASE, NAME);
87+
transaction = new FakeTransaction();
7588
});
7689

7790
afterEach(() => sandbox.restore());
@@ -107,16 +120,16 @@ describe('Table', () => {
107120

108121
describe('createReadStream', () => {
109122
let fakeReadStream: Transform;
110-
let getSnapshotStub: sinon.SinonStub;
123+
let getSnapshotStub: sinon.SinonStub<[TimestampBounds, GetSnapshotCallback], void>;
111124

112125
const REQUEST = {keys: ['key']};
113126

114127
beforeEach(() => {
115128
fakeReadStream = through.obj();
116-
sandbox.stub(TRANSACTION, 'createReadStream').returns(fakeReadStream);
129+
sandbox.stub(transaction, 'createReadStream').returns(fakeReadStream);
117130
getSnapshotStub =
118131
sandbox.stub(DATABASE, 'getSnapshot')
119-
.callsFake((_, callback) => callback(null, TRANSACTION));
132+
.callsFake((_, callback) => callback(null, transaction));
120133
});
121134

122135
it('should destroy the user stream if unable to get a snapshot', done => {
@@ -141,7 +154,7 @@ describe('Table', () => {
141154
});
142155

143156
it('should destroy the user stream and end the txn on error', done => {
144-
const endStub = sandbox.stub(TRANSACTION, 'end');
157+
const endStub = sandbox.stub(transaction, 'end');
145158
const fakeError = new Error('err');
146159

147160
table.createReadStream(REQUEST).on('error', err => {
@@ -170,7 +183,7 @@ describe('Table', () => {
170183
});
171184

172185
it('should end the transaction on stream end', done => {
173-
sandbox.stub(TRANSACTION, 'end').callsFake(done);
186+
sandbox.stub(transaction, 'end').callsFake(done);
174187
table.createReadStream(REQUEST).on('error', done);
175188
fakeReadStream.end();
176189
});
@@ -219,9 +232,9 @@ describe('Table', () => {
219232

220233
it('should delete the rows via transaction', done => {
221234
const stub =
222-
sandbox.stub(TRANSACTION, 'deleteRows').withArgs(table.name, KEYS);
235+
sandbox.stub(transaction, 'deleteRows').withArgs(table.name, KEYS);
223236

224-
sandbox.stub(TRANSACTION, 'commit').callsFake(callback => callback());
237+
sandbox.stub(transaction, 'commit').callsFake(callback => callback());
225238

226239
table.deleteRows(KEYS, err => {
227240
assert.ifError(err);
@@ -263,7 +276,7 @@ describe('Table', () => {
263276

264277
it('should insert via transaction', done => {
265278
const stub =
266-
sandbox.stub(TRANSACTION, 'insert').withArgs(table.name, ROW);
279+
sandbox.stub(transaction, 'insert').withArgs(table.name, ROW);
267280

268281
table.insert(ROW, err => {
269282
assert.ifError(err);
@@ -354,7 +367,7 @@ describe('Table', () => {
354367

355368
it('should replace via transaction', done => {
356369
const stub =
357-
sandbox.stub(TRANSACTION, 'replace').withArgs(table.name, ROW);
370+
sandbox.stub(transaction, 'replace').withArgs(table.name, ROW);
358371

359372
table.replace(ROW, err => {
360373
assert.ifError(err);
@@ -381,7 +394,7 @@ describe('Table', () => {
381394

382395
it('should update via transaction', done => {
383396
const stub =
384-
sandbox.stub(TRANSACTION, 'update').withArgs(table.name, ROW);
397+
sandbox.stub(transaction, 'update').withArgs(table.name, ROW);
385398

386399
table.update(ROW, err => {
387400
assert.ifError(err);
@@ -408,7 +421,7 @@ describe('Table', () => {
408421

409422
it('should upsert via transaction', done => {
410423
const stub =
411-
sandbox.stub(TRANSACTION, 'upsert').withArgs(table.name, ROW);
424+
sandbox.stub(transaction, 'upsert').withArgs(table.name, ROW);
412425

413426
table.upsert(ROW, err => {
414427
assert.ifError(err);

0 commit comments

Comments
 (0)