Skip to content
This repository was archived by the owner on Mar 26, 2026. It is now read-only.

Commit 4d1652d

Browse files
authored
test: Remove sinon clock dependency to unblock the CI pipeline (#1624)
* Debugging attempts * Remove the sinon clock * Add all the tests back in * still include the sinon stub * Remove chunk transformer handler * formatting changes * Add space * Add space * remove only
1 parent f8fd4be commit 4d1652d

2 files changed

Lines changed: 32 additions & 32 deletions

File tree

system-test/data/read-rows-retry-test.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@
149149
{ "startKeyClosed": "a", "endKeyClosed": "c" },
150150
{ "startKeyClosed": "x", "endKeyClosed": "z" }
151151
] },
152-
{ "rowKeys": [],
152+
{ "rowKeys": [],
153153
"rowRanges": [ { "startKeyClosed": "x", "endKeyClosed": "z" } ] }
154154
],
155155
"responses": [

system-test/read-rows.ts

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {EventEmitter} from 'events';
2525
import {Test} from './testTypes';
2626
import {ServiceError, GrpcClient, GoogleError, CallOptions} from 'google-gax';
2727
import {PassThrough} from 'stream';
28+
import * as mocha from 'mocha';
2829

2930
const {grpc} = new GrpcClient();
3031

@@ -124,7 +125,6 @@ describe('Bigtable/Table', () => {
124125
});
125126

126127
describe('createReadStream', () => {
127-
let clock: sinon.SinonFakeTimers;
128128
let endCalled: boolean;
129129
let error: ServiceError | null;
130130
let requestedOptions: Array<{}>;
@@ -133,18 +133,6 @@ describe('Bigtable/Table', () => {
133133
let stub: sinon.SinonStub;
134134

135135
beforeEach(() => {
136-
clock = sinon.useFakeTimers({
137-
toFake: [
138-
'setTimeout',
139-
'clearTimeout',
140-
'setImmediate',
141-
'clearImmediate',
142-
'setInterval',
143-
'clearInterval',
144-
'Date',
145-
'nextTick',
146-
],
147-
});
148136
endCalled = false;
149137
error = null;
150138
responses = null;
@@ -186,34 +174,46 @@ describe('Bigtable/Table', () => {
186174
});
187175

188176
afterEach(() => {
189-
clock.restore();
190177
stub.restore();
191178
});
192179

193180
tests.forEach(test => {
194-
it(test.name, () => {
181+
it(test.name, (done: mocha.Done) => {
195182
responses = test.responses;
196183
TABLE.maxRetries = test.max_retries;
197184
TABLE.createReadStream(test.createReadStream_options)
198185
.on('data', row => rowKeysRead[rowKeysRead.length - 1].push(row.id))
199-
.on('end', () => (endCalled = true))
200-
.on('error', err => (error = err as ServiceError));
201-
clock.runAll();
186+
.on('end', () => {
187+
endCalled = true;
188+
doAssertionChecks();
189+
})
190+
.on('error', err => {
191+
error = err as ServiceError;
192+
doAssertionChecks();
193+
});
202194

203-
if (test.error) {
204-
assert(!endCalled, ".on('end') should not have been invoked");
205-
assert.strictEqual(error!.code, test.error);
206-
} else {
207-
assert(endCalled, ".on('end') shoud have been invoked");
208-
assert.ifError(error);
195+
function doAssertionChecks() {
196+
try {
197+
if (test.error) {
198+
assert(!endCalled, ".on('end') should not have been invoked");
199+
assert.strictEqual(error!.code, test.error);
200+
} else {
201+
assert(endCalled, ".on('end') shoud have been invoked");
202+
assert.ifError(error);
203+
}
204+
assert.deepStrictEqual(rowKeysRead, test.row_keys_read);
205+
assert(responses);
206+
assert.strictEqual(
207+
responses.length,
208+
0,
209+
'not all the responses were used',
210+
);
211+
assert.deepStrictEqual(requestedOptions, test.request_options);
212+
done();
213+
} catch (e) {
214+
done(e);
215+
}
209216
}
210-
assert.deepStrictEqual(rowKeysRead, test.row_keys_read);
211-
assert.strictEqual(
212-
responses.length,
213-
0,
214-
'not all the responses were used',
215-
);
216-
assert.deepStrictEqual(requestedOptions, test.request_options);
217217
});
218218
});
219219
});

0 commit comments

Comments
 (0)