Skip to content

Commit

Permalink
test: Make the mock server test async (googleapis#1283)
Browse files Browse the repository at this point in the history
* Make the mock server test async

This test uses the done callback which looks confusing. We should. make the test async for readability.

* test: Make the mock server test async

* Remove the unnecessary before block

The service does not need to be initialized in a before block. Move it to where the server is initialized.
  • Loading branch information
danieljbruce authored May 19, 2023
1 parent 436e778 commit 6bda5be
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions test/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,21 @@ describe('Bigtable/Errors', () => {
let server: MockServer;
let bigtable: Bigtable;
let table: any;
let service: MockService;

before(done => {
server = new MockServer(() => {
bigtable = new Bigtable({
apiEndpoint: `localhost:${server.port}`,
});
table = bigtable.instance('fake-instance').table('fake-table');
done();
before(async () => {
// make sure we have everything initialized before starting tests
const port = await new Promise<string>(resolve => {
server = new MockServer(resolve);
});
bigtable = new Bigtable({
apiEndpoint: `localhost:${port}`,
});
service = new BigtableClientMockService(server);
table = bigtable.instance('fake-instance').table('fake-table');
});

describe('with the bigtable data client', () => {
let service: MockService;
before(async () => {
service = new BigtableClientMockService(server);
});

describe('sends errors through a streaming request', () => {
const errorDetails =
'Table not found: projects/my-project/instances/my-instance/tables/my-table';
Expand Down

0 comments on commit 6bda5be

Please sign in to comment.