Skip to content

Commit

Permalink
test for batchWrite
Browse files Browse the repository at this point in the history
  • Loading branch information
alkatrivedi committed May 31, 2024
1 parent ce3bc03 commit ac03ebb
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions test/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,6 @@ describe('Database', () => {
let fakeDataStream: Transform;
let fakeMutationGroup: FakeTransaction;
let fakeMutationGroup2: FakeTransaction;

let getSessionStub: sinon.SinonStub;
let requestStreamStub: sinon.SinonStub;
let batchWriteStub: sinon.SinonStub;
Expand All @@ -614,7 +613,6 @@ describe('Database', () => {
fakeMutationGroup2 = new FakeTransaction(

Check failure on line 613 in test/database.ts

View workflow job for this annotation

GitHub Actions / lint

'fakeMutationGroup2' is never reassigned. Use 'const' instead
{} as google.spanner.v1.BatchWriteRequest.MutationGroup
);
let fakeStream: Transform;

beforeEach(() => {
fakePool = database.pool_;
Expand All @@ -631,7 +629,7 @@ describe('Database', () => {

batchWriteStub = sandbox
.stub(fakeMutationGroup, 'batchWrite')

Check failure on line 631 in test/database.ts

View workflow job for this annotation

GitHub Actions / lint

Insert `··`
.returns(fakeStream);
.returns(fakeDataStream);

Check failure on line 632 in test/database.ts

View workflow job for this annotation

GitHub Actions / lint

Insert `··`
});

it('should get a session via `getSession`', () => {
Expand Down Expand Up @@ -660,6 +658,14 @@ describe('Database', () => {
});

Check failure on line 658 in test/database.ts

View workflow job for this annotation

GitHub Actions / lint

Delete `··`
});

it('should return data when passing a valid list of mutationGroups', done => {
database.batchWrite(mutationGroups, fakeOptions)
.on('data', data => {
console.error('Data:', data);
done();
});
});

it('should call `requestStream` with correct arguments', () => {
const expectedReqOpts = {
session: fakeSession ? fakeSession.formattedName_! : undefined,
Expand Down

0 comments on commit ac03ebb

Please sign in to comment.