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

feat(deps): template change for new gts dependency #354

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from 6 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
6 changes: 6 additions & 0 deletions baselines/bigquery-storage/.eslintignore.baseline
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
**/node_modules
**/.coverage
build/
docs/
protos/
system-test/
3 changes: 3 additions & 0 deletions baselines/bigquery-storage/.eslintrc.json.baseline
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "./node_modules/gts"
}
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ export class BigQueryStorageClient {
this.bigQueryStorageStub = this._gaxGrpc.createStub(
this._opts.fallback ?
(this._protos as protobuf.Root).lookupService('google.cloud.bigquery.storage.v1beta1.BigQueryStorage') :
// tslint:disable-next-line no-any
/* eslint-disable @typescript-eslint/no-explicit-any */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need both eslint-disable and tsline:disable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right! :) we just need eslint-disable, thank you! also removed tslint in base PR, thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it does not work without the latest version of gts. This PR was intended to make some pure template change before updating gts, but seems this is more and more overlapped with the gts PR, I may close this later on and resolve all related problems in the base PR: #343

(this._protos as any).google.cloud.bigquery.storage.v1beta1.BigQueryStorage,
this._opts) as Promise<{[method: string]: Function}>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import * as protosTypes from '../protos/protos';
import * as assert from 'assert';
import { describe, it } from 'mocha';
/* eslint-disable @typescript-eslint/no-var-requires */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated, but I would love to have a proper import here (I remember there were some types problems when we tried it).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, Justin also brought this up in the other PR, import module will bring types in. Basically it's about mock methods like client._innerApiCalls.echo, while _innerApiCalls is private in EchoClient do we want to fix them now? Thank you!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you spend an hour (but not more) on that? If we can make innerApiCalls public (I don't see any real harm about doing it) it might become possible to import and mock it properly. If you figure out you need more changes, then let's leave it as is.

A better alternative is to move unit tests to sinon, removing all the custom mocks :) But this will take more time and we're probably not going to do it now.

const bigquerystorageModule = require('../src');

import {PassThrough} from 'stream';
Expand All @@ -41,7 +42,9 @@ export interface Callback {
}

export class Operation{
/* eslint-disable @typescript-eslint/no-empty-function */
constructor(){};
/* eslint-disable @typescript-eslint/no-empty-function */
promise() {};
}
function mockSimpleGrpcMethod(expectedRequest: {}, response: {} | null, error: FakeError | null) {
Expand Down Expand Up @@ -155,8 +158,6 @@ describe('v1beta1.BigQueryStorageClient', () => {
request.tableReference.projectId = '';
request.tableReference = {};
request.tableReference.datasetId = '';
// Mock response
const expectedResponse = {};
// Mock gRPC layer
client._innerApiCalls.createReadSession = mockSimpleGrpcMethod(
request,
Expand Down Expand Up @@ -209,8 +210,6 @@ describe('v1beta1.BigQueryStorageClient', () => {
const request: protosTypes.google.cloud.bigquery.storage.v1beta1.IBatchCreateReadSessionStreamsRequest = {};
request.session = {};
request.session.name = '';
// Mock response
const expectedResponse = {};
// Mock gRPC layer
client._innerApiCalls.batchCreateReadSessionStreams = mockSimpleGrpcMethod(
request,
Expand Down Expand Up @@ -263,8 +262,6 @@ describe('v1beta1.BigQueryStorageClient', () => {
const request: protosTypes.google.cloud.bigquery.storage.v1beta1.IFinalizeStreamRequest = {};
request.stream = {};
request.stream.name = '';
// Mock response
const expectedResponse = {};
// Mock gRPC layer
client._innerApiCalls.finalizeStream = mockSimpleGrpcMethod(
request,
Expand Down Expand Up @@ -317,8 +314,6 @@ describe('v1beta1.BigQueryStorageClient', () => {
const request: protosTypes.google.cloud.bigquery.storage.v1beta1.ISplitReadStreamRequest = {};
request.originalStream = {};
request.originalStream.name = '';
// Mock response
const expectedResponse = {};
// Mock gRPC layer
client._innerApiCalls.splitReadStream = mockSimpleGrpcMethod(
request,
Expand Down Expand Up @@ -372,8 +367,6 @@ describe('v1beta1.BigQueryStorageClient', () => {
request.readPosition = {};
request.readPosition.stream = {};
request.readPosition.stream.name = '';
// Mock response
const expectedResponse = {};
// Mock gRPC layer
client._innerApiCalls.readRows = mockServerStreamingGrpcMethod(request, null, error);
const stream = client.readRows(request);
Expand Down
6 changes: 6 additions & 0 deletions baselines/disable-packing-test/.eslintignore.baseline
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
**/node_modules
**/.coverage
build/
docs/
protos/
system-test/
3 changes: 3 additions & 0 deletions baselines/disable-packing-test/.eslintrc.json.baseline
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "./node_modules/gts"
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
// ** All changes to this file may be overwritten. **

import * as gax from 'google-gax';
import {APICallback, Callback, CallOptions, Descriptors, ClientOptions, LROperation, PaginationCallback, PaginationResponse} from 'google-gax';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmmm. Maybe it's better to start actually using these types if possible? :) (in the client template, line 551 and nearby)

import {APICallback, Callback, CallOptions, Descriptors, ClientOptions, LROperation} from 'google-gax';
import * as path from 'path';

import { Transform } from 'stream';
Expand Down Expand Up @@ -185,6 +185,7 @@ export class EchoClient {
// an Operation object that allows for tracking of the operation,
// rather than holding a request open.
const protoFilesRoot = opts.fallback?
/* eslint-disable @typescript-eslint/no-var-requires */
this._gaxModule.protobuf.Root.fromJSON(require("../../protos/protos.json")) :
this._gaxModule.protobuf.loadSync(nodejsProtoPath);

Expand Down Expand Up @@ -237,7 +238,7 @@ export class EchoClient {
this.echoStub = this._gaxGrpc.createStub(
this._opts.fallback ?
(this._protos as protobuf.Root).lookupService('google.showcase.v1beta1.Echo') :
// tslint:disable-next-line no-any
/* eslint-disable @typescript-eslint/no-explicit-any */
(this._protos as any).google.showcase.v1beta1.Echo,
this._opts) as Promise<{[method: string]: Function}>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
// ** All changes to this file may be overwritten. **

import * as gax from 'google-gax';
import {APICallback, Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, PaginationResponse} from 'google-gax';
import {APICallback, Callback, CallOptions, Descriptors, ClientOptions} from 'google-gax';
import * as path from 'path';

import { Transform } from 'stream';
Expand Down Expand Up @@ -201,7 +201,7 @@ export class IdentityClient {
this.identityStub = this._gaxGrpc.createStub(
this._opts.fallback ?
(this._protos as protobuf.Root).lookupService('google.showcase.v1beta1.Identity') :
// tslint:disable-next-line no-any
/* eslint-disable @typescript-eslint/no-explicit-any */
(this._protos as any).google.showcase.v1beta1.Identity,
this._opts) as Promise<{[method: string]: Function}>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
// ** All changes to this file may be overwritten. **

import * as gax from 'google-gax';
import {APICallback, Callback, CallOptions, Descriptors, ClientOptions, LROperation, PaginationCallback, PaginationResponse} from 'google-gax';
import {APICallback, Callback, CallOptions, Descriptors, ClientOptions, LROperation} from 'google-gax';
import * as path from 'path';

import { Transform } from 'stream';
Expand Down Expand Up @@ -186,6 +186,7 @@ export class MessagingClient {
// an Operation object that allows for tracking of the operation,
// rather than holding a request open.
const protoFilesRoot = opts.fallback?
/* eslint-disable @typescript-eslint/no-var-requires */
this._gaxModule.protobuf.Root.fromJSON(require("../../protos/protos.json")) :
this._gaxModule.protobuf.loadSync(nodejsProtoPath);

Expand Down Expand Up @@ -238,7 +239,7 @@ export class MessagingClient {
this.messagingStub = this._gaxGrpc.createStub(
this._opts.fallback ?
(this._protos as protobuf.Root).lookupService('google.showcase.v1beta1.Messaging') :
// tslint:disable-next-line no-any
/* eslint-disable @typescript-eslint/no-explicit-any */
(this._protos as any).google.showcase.v1beta1.Messaging,
this._opts) as Promise<{[method: string]: Function}>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
// ** All changes to this file may be overwritten. **

import * as gax from 'google-gax';
import {APICallback, Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, PaginationResponse} from 'google-gax';
import {APICallback, Callback, CallOptions, Descriptors, ClientOptions} from 'google-gax';
import * as path from 'path';

import { Transform } from 'stream';
Expand Down Expand Up @@ -204,7 +204,7 @@ export class TestingClient {
this.testingStub = this._gaxGrpc.createStub(
this._opts.fallback ?
(this._protos as protobuf.Root).lookupService('google.showcase.v1beta1.Testing') :
// tslint:disable-next-line no-any
/* eslint-disable @typescript-eslint/no-explicit-any */
(this._protos as any).google.showcase.v1beta1.Testing,
this._opts) as Promise<{[method: string]: Function}>;

Expand Down
13 changes: 3 additions & 10 deletions baselines/disable-packing-test/test/gapic-echo-v1beta1.ts.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import * as protosTypes from '../protos/protos';
import * as assert from 'assert';
import { describe, it } from 'mocha';
/* eslint-disable @typescript-eslint/no-var-requires */
const echoModule = require('../src');

import {PassThrough} from 'stream';
Expand All @@ -41,7 +42,9 @@ export interface Callback {
}

export class Operation{
/* eslint-disable @typescript-eslint/no-empty-function */
constructor(){};
/* eslint-disable @typescript-eslint/no-empty-function */
promise() {};
}
function mockSimpleGrpcMethod(expectedRequest: {}, response: {} | null, error: FakeError | null) {
Expand Down Expand Up @@ -182,8 +185,6 @@ describe('v1beta1.EchoClient', () => {
client.initialize();
// Mock request
const request: protosTypes.google.showcase.v1beta1.IEchoRequest = {};
// Mock response
const expectedResponse = {};
// Mock gRPC layer
client._innerApiCalls.echo = mockSimpleGrpcMethod(
request,
Expand Down Expand Up @@ -232,8 +233,6 @@ describe('v1beta1.EchoClient', () => {
client.initialize();
// Mock request
const request: protosTypes.google.showcase.v1beta1.IBlockRequest = {};
// Mock response
const expectedResponse = {};
// Mock gRPC layer
client._innerApiCalls.block = mockSimpleGrpcMethod(
request,
Expand Down Expand Up @@ -285,8 +284,6 @@ describe('v1beta1.EchoClient', () => {
client.initialize();
// Mock request
const request: protosTypes.google.showcase.v1beta1.IWaitRequest = {};
// Mock response
const expectedResponse = {};
// Mock gRPC layer
client._innerApiCalls.wait = mockLongRunningGrpcMethod(
request,
Expand Down Expand Up @@ -338,8 +335,6 @@ describe('v1beta1.EchoClient', () => {
client.initialize();
// Mock request
const request: protosTypes.google.showcase.v1beta1.IExpandRequest = {};
// Mock response
const expectedResponse = {};
// Mock gRPC layer
client._innerApiCalls.expand = mockServerStreamingGrpcMethod(request, null, error);
const stream = client.expand(request);
Expand Down Expand Up @@ -385,8 +380,6 @@ describe('v1beta1.EchoClient', () => {
client.initialize();
// Mock request
const request: protosTypes.google.showcase.v1beta1.IEchoRequest = {};
// Mock response
const expectedResponse = {};
// Mock gRPC layer
client._innerApiCalls.chat = mockBidiStreamingGrpcMethod(request, null, error);
const stream = client.chat().on('data', () =>{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import * as protosTypes from '../protos/protos';
import * as assert from 'assert';
import { describe, it } from 'mocha';
/* eslint-disable @typescript-eslint/no-var-requires */
const identityModule = require('../src');


Expand All @@ -39,7 +40,9 @@ export interface Callback {
}

export class Operation{
/* eslint-disable @typescript-eslint/no-empty-function */
constructor(){};
/* eslint-disable @typescript-eslint/no-empty-function */
promise() {};
}
function mockSimpleGrpcMethod(expectedRequest: {}, response: {} | null, error: FakeError | null) {
Expand Down Expand Up @@ -128,8 +131,6 @@ describe('v1beta1.IdentityClient', () => {
client.initialize();
// Mock request
const request: protosTypes.google.showcase.v1beta1.ICreateUserRequest = {};
// Mock response
const expectedResponse = {};
// Mock gRPC layer
client._innerApiCalls.createUser = mockSimpleGrpcMethod(
request,
Expand Down Expand Up @@ -180,8 +181,6 @@ describe('v1beta1.IdentityClient', () => {
// Mock request
const request: protosTypes.google.showcase.v1beta1.IGetUserRequest = {};
request.name = '';
// Mock response
const expectedResponse = {};
// Mock gRPC layer
client._innerApiCalls.getUser = mockSimpleGrpcMethod(
request,
Expand Down Expand Up @@ -234,8 +233,6 @@ describe('v1beta1.IdentityClient', () => {
const request: protosTypes.google.showcase.v1beta1.IUpdateUserRequest = {};
request.user = {};
request.user.name = '';
// Mock response
const expectedResponse = {};
// Mock gRPC layer
client._innerApiCalls.updateUser = mockSimpleGrpcMethod(
request,
Expand Down Expand Up @@ -286,8 +283,6 @@ describe('v1beta1.IdentityClient', () => {
// Mock request
const request: protosTypes.google.showcase.v1beta1.IDeleteUserRequest = {};
request.name = '';
// Mock response
const expectedResponse = {};
// Mock gRPC layer
client._innerApiCalls.deleteUser = mockSimpleGrpcMethod(
request,
Expand Down
Loading