Skip to content

Commit

Permalink
feat: add tests and samples to library (#9)
Browse files Browse the repository at this point in the history
* feat: add tests and samples to library

* 🦉 Updates from OwlBot

See https://github.com/googleapis/repo-automation-bots/blob/master/packages/owl-bot/README.md
Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
  • Loading branch information
sofisl authored Jun 30, 2021
1 parent 8b833c4 commit 78ee03b
Show file tree
Hide file tree
Showing 12 changed files with 102 additions and 134 deletions.
2 changes: 1 addition & 1 deletion packages/google-cloud-lifesciences/.jsdoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ module.exports = {
copyright: 'Copyright 2021 Google LLC',
includeDate: false,
sourceFiles: false,
systemName: '@google-cloud/lifesciences',
systemName: '@google-cloud/life-sciences',
theme: 'lumen',
default: {
outputSourceFiles: false
Expand Down
23 changes: 9 additions & 14 deletions packages/google-cloud-lifesciences/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,27 +60,22 @@ npm install @google-cloud/life-sciences
```javascript
// Imports the Google Cloud client library

// remove this line after package is released
// eslint-disable-next-line node/no-missing-require
const {WorkflowsServiceV2BetaClient} = require('@google-cloud/life-sciences');

// TODO(developer): replace with your prefered project ID.
// const projectId = 'my-project'
// const pipeline = 'name-of-pipeline', i.e., 1234
// const projectId = your-project-id
// const location = your-pipeline-location

// Creates a client
// eslint-disable-next-line no-unused-vars
const client = new {WorkflowsServiceV2BetaClient}();
const client = new WorkflowsServiceV2BetaClient();

//TODO(library generator): write the actual function you will be testing
async function doSomething() {
console.log(
'DPE! Change this code so that it shows how to use the library! See comments below on structure.'
async function checkPipelineProgress() {
const status = await client.checkRunPipelineProgress(
`projects/${projectId}/locations/${location}/operations/${pipeline}`
);
// const [thing] = await client.methodName({
// });
// console.info(thing);
console.info(status);
}
doSomething();
checkPipelineProgress();

```

Expand Down
2 changes: 1 addition & 1 deletion packages/google-cloud-lifesciences/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@google-cloud/life-sciences",
"version": "0.1.0",
"description": "lifesciences client for Node.js",
"repository": "googleapis/googleapis/nodejs-life-sciences",
"repository": "googleapis/nodejs-life-sciences",
"license": "Apache-2.0",
"author": "Google LLC",
"main": "build/src/index.js",
Expand Down
10 changes: 5 additions & 5 deletions packages/google-cloud-lifesciences/protos/protos.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 10 additions & 10 deletions packages/google-cloud-lifesciences/protos/protos.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 10 additions & 15 deletions packages/google-cloud-lifesciences/samples/quickstart.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,26 @@

'use strict';

async function main() {
async function main(projectId, location, pipeline) {
// [START nodejs_life_sciences_quickstart]
// Imports the Google Cloud client library

// remove this line after package is released
// eslint-disable-next-line node/no-missing-require
const {WorkflowsServiceV2BetaClient} = require('@google-cloud/life-sciences');

// TODO(developer): replace with your prefered project ID.
// const projectId = 'my-project'
// const pipeline = 'name-of-pipeline', i.e., 1234
// const projectId = your-project-id
// const location = your-pipeline-location

// Creates a client
// eslint-disable-next-line no-unused-vars
const client = new {WorkflowsServiceV2BetaClient}();
const client = new WorkflowsServiceV2BetaClient();

//TODO(library generator): write the actual function you will be testing
async function doSomething() {
console.log(
'DPE! Change this code so that it shows how to use the library! See comments below on structure.'
async function checkPipelineProgress() {
const status = await client.checkRunPipelineProgress(
`projects/${projectId}/locations/${location}/operations/${pipeline}`
);
// const [thing] = await client.methodName({
// });
// console.info(thing);
console.info(status);
}
doSomething();
checkPipelineProgress();
// [END nodejs_life_sciences_quickstart]
}

Expand Down
25 changes: 7 additions & 18 deletions packages/google-cloud-lifesciences/samples/test/quickstart.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,32 +19,21 @@

const path = require('path');
const cp = require('child_process');
const {before, describe, it} = require('mocha');
const {describe, it} = require('mocha');
// eslint-disable-next-line node/no-missing-require
const {WorkflowsServiceV2BetaClient} = require('@google-cloud/life-sciences');
// eslint-disable-next-line no-unused-vars, node/no-missing-require
const {assert} = require('chai');

const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'});

const cwd = path.join(__dirname, '..');

const client = new {WorkflowsServiceV2BetaClient}();

describe('Quickstart', () => {
//TODO: remove this if not using the projectId
// eslint-disable-next-line no-unused-vars
let projectId;

before(async () => {
// eslint-disable-next-line no-unused-vars
projectId = await client.getProjectId();
});

it('should run quickstart', async () => {
//TODO: remove this line
// eslint-disable-next-line no-unused-vars
const stdout = execSync('node ./quickstart.js', {cwd});
//assert(stdout, stdout !== null);
const stdout = execSync(
'node ./quickstart.js long-door-651 us-central1 15945335513149178558',
{cwd}
);
// eslint-disable-next-line no-undef
assert.match(stdout, /Operation/);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"comment": "This file maps proto services/RPCs to the corresponding library clients/methods",
"language": "typescript",
"protoPackage": "google.cloud.lifesciences.v2beta",
"libraryPackage": "@google-cloud/lifesciences",
"libraryPackage": "@google-cloud/life-sciences",
"services": {
"WorkflowsServiceV2Beta": {
"clients": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,13 +224,14 @@ export class WorkflowsServiceV2BetaClient {
const workflowsServiceV2BetaStubMethods = ['runPipeline'];
for (const methodName of workflowsServiceV2BetaStubMethods) {
const callPromise = this.workflowsServiceV2BetaStub.then(
stub => (...args: Array<{}>) => {
if (this._terminated) {
return Promise.reject('The client has already been closed.');
}
const func = stub[methodName];
return func.apply(stub, args);
},
stub =>
(...args: Array<{}>) => {
if (this._terminated) {
return Promise.reject('The client has already been closed.');
}
const func = stub[methodName];
return func.apply(stub, args);
},
(err: Error | null | undefined) => () => {
throw err;
}
Expand Down Expand Up @@ -304,7 +305,7 @@ export class WorkflowsServiceV2BetaClient {
// -------------------

runPipeline(
request: protos.google.cloud.lifesciences.v2beta.IRunPipelineRequest,
request?: protos.google.cloud.lifesciences.v2beta.IRunPipelineRequest,
options?: CallOptions
): Promise<
[
Expand Down Expand Up @@ -390,7 +391,7 @@ export class WorkflowsServiceV2BetaClient {
* const [response] = await operation.promise();
*/
runPipeline(
request: protos.google.cloud.lifesciences.v2beta.IRunPipelineRequest,
request?: protos.google.cloud.lifesciences.v2beta.IRunPipelineRequest,
optionsOrCallback?:
| CallOptions
| Callback<
Expand Down Expand Up @@ -430,11 +431,10 @@ export class WorkflowsServiceV2BetaClient {
options = options || {};
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
options.otherArgs.headers[
'x-goog-request-params'
] = gax.routingHeader.fromParams({
parent: request.parent || '',
});
options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
parent: request.parent || '',
});
this.initialize();
return this.innerApiCalls.runPipeline(request, options, callback);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@
// ** All changes to this file may be overwritten. **

/* eslint-disable node/no-missing-require, no-unused-vars */
const lifesciences = require('@google-cloud/lifesciences');
const lifesciences = require('@google-cloud/life-sciences');

function main() {
const workflowsServiceV2BetaClient = new lifesciences.WorkflowsServiceV2BetaClient();
const workflowsServiceV2BetaClient =
new lifesciences.WorkflowsServiceV2BetaClient();
}

main();
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// ** https://github.com/googleapis/gapic-generator-typescript **
// ** All changes to this file may be overwritten. **

import {WorkflowsServiceV2BetaClient} from '@google-cloud/lifesciences';
import {WorkflowsServiceV2BetaClient} from '@google-cloud/life-sciences';

// check that the client class type name can be used
function doStuffWithWorkflowsServiceV2BetaClient(
Expand Down
Loading

0 comments on commit 78ee03b

Please sign in to comment.