Skip to content

Commit

Permalink
feat: add initial samples and tests (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
sofisl authored Mar 26, 2021
1 parent 84dc617 commit ebe00c4
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 48 deletions.
2 changes: 1 addition & 1 deletion packages/google-appengine/.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/appengine',
systemName: '@google-cloud/appengine-admin',
theme: 'lumen',
default: {
outputSourceFiles: false
Expand Down
22 changes: 9 additions & 13 deletions packages/google-appengine/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,25 +60,21 @@ npm install @google-cloud/appengine-admin
```javascript
// Imports the Google Cloud client library

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

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

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

//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.')
// const [thing] = await client.methodName({
// });
// console.info(thing);
const client = new ServicesClient();

async function listVersions() {
const [versions] = await client.listServices({
parent: `apps/${projectId}`,
});
console.info([versions]);
}
doSomething();
listVersions();

```

Expand Down
12 changes: 11 additions & 1 deletion packages/google-appengine/linkinator.config.json
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
{"recurse":true,"skip":["https://codecov.io/gh/googleapis/","www.googleapis.com","img.shields.io"],"silent":true,"concurrency":10}
{
"recurse": true,
"skip": [
"https://github.com/googleapis/nodejs-appengine-admin/blob/master/CHANGELOG.md",
"https://codecov.io/gh/googleapis/",
"www.googleapis.com",
"img.shields.io"
],
"silent": true,
"concurrency": 10
}
4 changes: 2 additions & 2 deletions packages/google-appengine/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@
"mocha": "^8.3.1",
"null-loader": "^4.0.1",
"pack-n-play": "^1.0.0-2",
"sinon": "^9.2.4",
"sinon": "^10.0.0",
"ts-loader": "^8.0.17",
"typescript": "^4.2.3",
"webpack": "^5.24.4",
"webpack-cli": "^4.5.0"
},
"engines": {
"node": ">=v10.24.0"
"node": ">=v10.0.0"
}
}
24 changes: 9 additions & 15 deletions packages/google-appengine/samples/quickstart.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,25 @@

'use strict';

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

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

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

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

//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.'
);
// const [thing] = await client.methodName({
// });
// console.info(thing);
async function listVersions() {
const [versions] = await client.listServices({
parent: `apps/${projectId}`,
});
console.info(versions);
}
doSomething();
listVersions();
// [END nodejs_appengine_admin_quickstart]
}

Expand Down
13 changes: 4 additions & 9 deletions packages/google-appengine/samples/test/quickstart.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,30 +21,25 @@ const path = require('path');
const cp = require('child_process');
const {before, describe, it} = require('mocha');
// eslint-disable-next-line node/no-missing-require
const {VersionsClient} = require('@google-cloud/appengine-admin');
const {ServicesClient} = require('@google-cloud/appengine-admin');
// 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 {VersionsClient}();
const client = new ServicesClient();

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 ${projectId}`, {cwd});
assert.match(stdout, /\[[\s\S]*\[[\s\S]*\][\s\S]*\]/);
});
});
8 changes: 4 additions & 4 deletions packages/google-appengine/synth.metadata
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
{
"git": {
"name": ".",
"remote": "sso://user/sofialeon/nodejs-appengine-admin",
"sha": "1b8bac63942e37e3123e19aaa02acd5f729327ca"
"remote": "git@github.com:googleapis/nodejs-appengine-admin.git",
"sha": "713ee9c67c67c88e284e5ae99a3b0db0dff0fe88"
}
},
{
"git": {
"name": "googleapis",
"remote": "https://github.com/googleapis/googleapis.git",
"sha": "5da78db589d423db6bcd6a35637c923fe1a7665c",
"internalRef": "363947872"
"sha": "6598bb829c9e9a534be674649ffd1b4671a821f9",
"internalRef": "364449524"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion packages/google-appengine/synth.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
name,
version,
bazel_target=f"//google/appengine/{version}:appengine-{version}-nodejs")
s.copy(library, excludes=["package.json","linkinator.config.json", "system-test/fixtures/sample/src/index.js","system-test/fixtures/sample/src/index.ts"])
s.copy(library, excludes=["package.json"])

# Copy common templates
common_templates = gcp.CommonTemplates()
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. **

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

function main() {
const applicationsClient = new appengine.ApplicationsClient();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
InstancesClient,
ServicesClient,
VersionsClient,
} from '@google-cloud/appengine';
} from '@google-cloud/appengine-admin';

// check that the client class type name can be used
function doStuffWithApplicationsClient(client: ApplicationsClient) {
Expand Down

0 comments on commit ebe00c4

Please sign in to comment.