Skip to content
This repository was archived by the owner on Jul 20, 2023. It is now read-only.
Merged
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
3 changes: 3 additions & 0 deletions samples/generated/v1/fleet_routing.batch_optimize_tours.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
function main(parent, modelConfigs) {
// [START cloudoptimization_v1_generated_FleetRouting_BatchOptimizeTours_async]
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
Expand Down
3 changes: 3 additions & 0 deletions samples/generated/v1/fleet_routing.optimize_tours.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
function main(parent) {
// [START cloudoptimization_v1_generated_FleetRouting_OptimizeTours_async]
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"segments": [
{
"start": 25,
"end": 224,
"end": 227,
"type": "FULL"
}
],
Expand Down Expand Up @@ -130,7 +130,7 @@
"segments": [
{
"start": 25,
"end": 59,
"end": 62,
"type": "FULL"
}
],
Expand Down
5 changes: 3 additions & 2 deletions src/v1/fleet_routing_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,8 @@ export class FleetRoutingClient {
const apiCall = this._gaxModule.createApiCall(
callPromise,
this._defaults[methodName],
descriptor
descriptor,
this._opts.fallback
);

this.innerApiCalls[methodName] = apiCall;
Expand Down Expand Up @@ -759,7 +760,7 @@ export class FleetRoutingClient {
const decodeOperation = new gax.Operation(
operation,
this.descriptors.longrunning.batchOptimizeTours,
gax.createDefaultBackoffSettings()
this._gaxModule.createDefaultBackoffSettings()
);
return decodeOperation as LROperation<
protos.google.cloud.optimization.v1.BatchOptimizeToursResponse,
Expand Down
156 changes: 79 additions & 77 deletions test/gapic_fleet_routing_v1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,99 +82,101 @@ function stubLongRunningCallWithCallback<ResponseType>(
}

describe('v1.FleetRoutingClient', () => {
it('has servicePath', () => {
const servicePath = fleetroutingModule.v1.FleetRoutingClient.servicePath;
assert(servicePath);
});

it('has apiEndpoint', () => {
const apiEndpoint = fleetroutingModule.v1.FleetRoutingClient.apiEndpoint;
assert(apiEndpoint);
});

it('has port', () => {
const port = fleetroutingModule.v1.FleetRoutingClient.port;
assert(port);
assert(typeof port === 'number');
});

it('should create a client with no option', () => {
const client = new fleetroutingModule.v1.FleetRoutingClient();
assert(client);
});
describe('Common methods', () => {
it('has servicePath', () => {
const servicePath = fleetroutingModule.v1.FleetRoutingClient.servicePath;
assert(servicePath);
});

it('should create a client with gRPC fallback', () => {
const client = new fleetroutingModule.v1.FleetRoutingClient({
fallback: true,
it('has apiEndpoint', () => {
const apiEndpoint = fleetroutingModule.v1.FleetRoutingClient.apiEndpoint;
assert(apiEndpoint);
});
assert(client);
});

it('has initialize method and supports deferred initialization', async () => {
const client = new fleetroutingModule.v1.FleetRoutingClient({
credentials: {client_email: 'bogus', private_key: 'bogus'},
projectId: 'bogus',
it('has port', () => {
const port = fleetroutingModule.v1.FleetRoutingClient.port;
assert(port);
assert(typeof port === 'number');
});
assert.strictEqual(client.fleetRoutingStub, undefined);
await client.initialize();
assert(client.fleetRoutingStub);
});

it('has close method for the initialized client', done => {
const client = new fleetroutingModule.v1.FleetRoutingClient({
credentials: {client_email: 'bogus', private_key: 'bogus'},
projectId: 'bogus',
it('should create a client with no option', () => {
const client = new fleetroutingModule.v1.FleetRoutingClient();
assert(client);
});
client.initialize();
assert(client.fleetRoutingStub);
client.close().then(() => {
done();

it('should create a client with gRPC fallback', () => {
const client = new fleetroutingModule.v1.FleetRoutingClient({
fallback: true,
});
assert(client);
});
});

it('has close method for the non-initialized client', done => {
const client = new fleetroutingModule.v1.FleetRoutingClient({
credentials: {client_email: 'bogus', private_key: 'bogus'},
projectId: 'bogus',
it('has initialize method and supports deferred initialization', async () => {
const client = new fleetroutingModule.v1.FleetRoutingClient({
credentials: {client_email: 'bogus', private_key: 'bogus'},
projectId: 'bogus',
});
assert.strictEqual(client.fleetRoutingStub, undefined);
await client.initialize();
assert(client.fleetRoutingStub);
});
assert.strictEqual(client.fleetRoutingStub, undefined);
client.close().then(() => {
done();

it('has close method for the initialized client', done => {
const client = new fleetroutingModule.v1.FleetRoutingClient({
credentials: {client_email: 'bogus', private_key: 'bogus'},
projectId: 'bogus',
});
client.initialize();
assert(client.fleetRoutingStub);
client.close().then(() => {
done();
});
});
});

it('has getProjectId method', async () => {
const fakeProjectId = 'fake-project-id';
const client = new fleetroutingModule.v1.FleetRoutingClient({
credentials: {client_email: 'bogus', private_key: 'bogus'},
projectId: 'bogus',
it('has close method for the non-initialized client', done => {
const client = new fleetroutingModule.v1.FleetRoutingClient({
credentials: {client_email: 'bogus', private_key: 'bogus'},
projectId: 'bogus',
});
assert.strictEqual(client.fleetRoutingStub, undefined);
client.close().then(() => {
done();
});
});
client.auth.getProjectId = sinon.stub().resolves(fakeProjectId);
const result = await client.getProjectId();
assert.strictEqual(result, fakeProjectId);
assert((client.auth.getProjectId as SinonStub).calledWithExactly());
});

it('has getProjectId method with callback', async () => {
const fakeProjectId = 'fake-project-id';
const client = new fleetroutingModule.v1.FleetRoutingClient({
credentials: {client_email: 'bogus', private_key: 'bogus'},
projectId: 'bogus',
it('has getProjectId method', async () => {
const fakeProjectId = 'fake-project-id';
const client = new fleetroutingModule.v1.FleetRoutingClient({
credentials: {client_email: 'bogus', private_key: 'bogus'},
projectId: 'bogus',
});
client.auth.getProjectId = sinon.stub().resolves(fakeProjectId);
const result = await client.getProjectId();
assert.strictEqual(result, fakeProjectId);
assert((client.auth.getProjectId as SinonStub).calledWithExactly());
});
client.auth.getProjectId = sinon
.stub()
.callsArgWith(0, null, fakeProjectId);
const promise = new Promise((resolve, reject) => {
client.getProjectId((err?: Error | null, projectId?: string | null) => {
if (err) {
reject(err);
} else {
resolve(projectId);
}

it('has getProjectId method with callback', async () => {
const fakeProjectId = 'fake-project-id';
const client = new fleetroutingModule.v1.FleetRoutingClient({
credentials: {client_email: 'bogus', private_key: 'bogus'},
projectId: 'bogus',
});
client.auth.getProjectId = sinon
.stub()
.callsArgWith(0, null, fakeProjectId);
const promise = new Promise((resolve, reject) => {
client.getProjectId((err?: Error | null, projectId?: string | null) => {
if (err) {
reject(err);
} else {
resolve(projectId);
}
});
});
const result = await promise;
assert.strictEqual(result, fakeProjectId);
});
const result = await promise;
assert.strictEqual(result, fakeProjectId);
});

describe('optimizeTours', () => {
Expand Down