Skip to content

Commit

Permalink
feat!: initial generation of library (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
bcoe committed Jul 9, 2021
0 parents commit 053ec0b
Show file tree
Hide file tree
Showing 3 changed files with 117 additions and 0 deletions.
23 changes: 23 additions & 0 deletions eventarc/quickstart/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "nodejs-eventarc",
"private": true,
"license": "Apache-2.0",
"author": "Google LLC",
"engines": {
"node": ">=10"
},
"files": [
"*.js"
],
"scripts": {
"test": "c8 mocha --timeout 600000 test/*.js"
},
"dependencies": {
"@google-cloud/eventarc": "^0.1.0"
},
"devDependencies": {
"c8": "^7.1.0",
"chai": "^4.2.0",
"mocha": "^8.0.0"
}
}
49 changes: 49 additions & 0 deletions eventarc/quickstart/quickstart.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

'use strict';

async function main(projectId) {
// [START nodejs_eventarc_quickstart]
// Imports the Google Cloud client library

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

// TODO(developer): replace with your prefered project ID.
// const projectId = 'my-project'

// Creates a client
const client = new EventarcClient();

//TODO(library generator): write the actual function you will be testing
async function doSomething() {
for await (const trigger of await client.listTriggersAsync({
parent: client.locationPath(projectId, 'us-central1'),
})) {
console.info(trigger.name);
}
}
doSomething();
// [END nodejs_eventarc_quickstart]
}

main(...process.argv.slice(2)).catch(err => {
console.error(err.message);
process.exitCode = 1;
});
process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
45 changes: 45 additions & 0 deletions eventarc/quickstart/test/quickstart.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// ** This file is automatically generated by gapic-generator-typescript. **
// ** https://github.com/googleapis/gapic-generator-typescript **
// ** All changes to this file may be overwritten. **

'use strict';

const path = require('path');
const cp = require('child_process');
const {before, describe, it} = require('mocha');
// eslint-disable-next-line node/no-missing-require
const {EventarcClient} = require('@google-cloud/eventarc');
// 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 EventarcClient();

describe('Quickstart', () => {
let projectId;

before(async () => {
projectId = await client.getProjectId();
});

it('should run quickstart', async () => {
const stdout = execSync(`node ./quickstart.js ${projectId}`, {cwd});
assert.strictEqual(stdout.includes('test-event-arc-api'), true);
});
});

0 comments on commit 053ec0b

Please sign in to comment.