Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(typescript): noImplicityAny for mutation test file #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
*/

import {promisifyAll} from '@google-cloud/promisify';
import {ServiceError} from '@grpc/grpc-js';
import {CallOptions, Operation as GaxOperation} from 'google-gax';
import {ServiceError} from 'grpc';

import {google as btTypes} from '../proto/bigtable';

Expand Down
2 changes: 1 addition & 1 deletion system-test/bigtable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

import * as assert from 'assert';
import Q = require('p-queue');
const Q = require('p-queue');
import * as uuid from 'uuid';

import {Bigtable} from '../src';
Expand Down
33 changes: 21 additions & 12 deletions test/mutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ import * as assert from 'assert';
import * as Long from 'long';
import * as sn from 'sinon';

import {IMutateRowRequest, Mutation} from '../src/mutation.js';
import {IMutateRowRequest, IMutation, Mutation, MutationConstructorObj, MutationSettingsObj, Value} from '../src/mutation.js';


const sinon = sn.createSandbox();

Expand Down Expand Up @@ -116,6 +117,7 @@ describe('Bigtable/Mutation', function() {
it('should pack numbers into int64 values', function() {
const num = 10;
const encoded = Mutation.convertToBytes(num);
// tslint:disable-next-line no-any
const decoded = Long.fromBytes(encoded as any).toNumber();

assert.strictEqual(num, decoded);
Expand Down Expand Up @@ -150,15 +152,17 @@ describe('Bigtable/Mutation', function() {
});

describe('encodeSetCell', function() {
let convertCalls;
let convertCalls: Value[];
// tslint:disable-next-line no-any
const fakeTime: any = new Date('2018-1-1');
// tslint:disable-next-line no-any
const realTimestamp: any = new Date();

beforeEach(function() {
sinon.stub(global, 'Date').returns(fakeTime);
convertCalls = [];
sinon.stub(Mutation, 'convertToBytes').callsFake(function(value) {
convertCalls.push(value);
convertCalls.push(value as Value);
return value;
});
});
Expand Down Expand Up @@ -252,7 +256,8 @@ describe('Bigtable/Mutation', function() {
});

describe('encodeDelete', function() {
let convert;
let convert: Function;
// tslint:disable-next-line no-any
let convertCalls: any[] = [];

before(function() {
Expand All @@ -264,7 +269,8 @@ describe('Bigtable/Mutation', function() {
});

after(function() {
Mutation.convertToBytes = convert;
sinon.stub(Mutation, 'convertToBytes').value(convert);
// Mutation.convertToBytes = convert;
});

beforeEach(function() {
Expand Down Expand Up @@ -332,6 +338,7 @@ describe('Bigtable/Mutation', function() {

it('should optionally accept a timerange for column requests', function() {
const createTimeRange = Mutation.createTimeRange;
// tslint:disable-next-line no-any
const timeCalls: any[] = [];
const fakeTimeRange = {a: 'a'};

Expand Down Expand Up @@ -371,7 +378,7 @@ describe('Bigtable/Mutation', function() {
});

describe('parse', function() {
let toProto;
let toProto: () => IMutateRowRequest;
let toProtoCalled = false;
const fakeData = {a: 'a'} as IMutateRowRequest;

Expand Down Expand Up @@ -431,7 +438,8 @@ describe('Bigtable/Mutation', function() {
});

describe('toProto', function() {
let convert;
let convert: Function;
// tslint:disable-next-line no-any
let convertCalls: any[] = [];

before(function() {
Expand All @@ -443,7 +451,7 @@ describe('Bigtable/Mutation', function() {
});

after(function() {
Mutation.convertToBytes = convert;
sinon.stub(Mutation, 'convertToBytes').value(convert);
});

beforeEach(function() {
Expand Down Expand Up @@ -473,17 +481,18 @@ describe('Bigtable/Mutation', function() {
});

it('should encode delete mutations when method is delete', function() {
const fakeEncoded = [{b: 'b'}];
const fakeEncoded = [{b: 'b'} as IMutation];
const data = {
key: 'b',
method: 'delete',
data: [],
};
} as MutationConstructorObj;

(Mutation as any).encodeDelete = function(_data) {
sinon.stub(Mutation, 'encodeDelete').callsFake((_data) => {
assert.strictEqual(_data, data.data);
return fakeEncoded;
};
});


const mutation = new Mutation(data).toProto();

Expand Down