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: replace system test with pack-n-play #132

Merged
merged 6 commits into from
Nov 13, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions templates/typescript_gapic/package.json.njk
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ limitations under the License.
"mocha": "^6.0.0",
"mv": "^2.1.1",
"ncp": "^2.0.0",
"pack-n-play": "^1.0.0-2",
"tmp": "^0.1.0",
"typescript": "^3.7.0"
},
Expand Down

This file was deleted.

This file was deleted.

49 changes: 15 additions & 34 deletions templates/typescript_gapic/system-test/install.ts.njk
Original file line number Diff line number Diff line change
Expand Up @@ -17,40 +17,21 @@ limitations under the License.
-#}
{% import "../_license.njk" as license -%}
{{license.license()}}
import * as execa from 'execa';
import * as mv from 'mv';
import {ncp} from 'ncp';
import * as tmp from 'tmp';
import {promisify} from 'util';

const keep = false;
const mvp = promisify(mv);
const ncpp = promisify(ncp);
const stagingDir = tmp.dirSync({keep, unsafeCleanup: true});
const stagingPath = stagingDir.name;
const pkg = require('../../package.json');

describe('📦 pack and install', () => {
it('should be able use the library from a TypeScript application', async function() {
import {packNTest} from 'pack-n-play';
import { readFileSync } from 'fs';

describe('typescript consumer tests', () => {

it('should have correct type signature for {{ api.naming.name }} client library', async function() {
this.timeout(300000);
await execa('npm', ['pack', '--unsafe-perm']);
const packageName = pkg.name.replace('@', '').replace('/', '-');
const tarball = `${packageName}-${pkg.version}.tgz`;
await mvp(tarball, `${stagingPath}/{{ api.naming.productName.toKebabCase() }}.tgz`);
await ncpp('system-test/fixtures/sample', `${stagingPath}/`);
await execa('npm', ['install', '--unsafe-perm'], {
cwd: `${stagingPath}/`,
stdio: 'inherit',
});
await execa('node', ['--throw-deprecation', 'build/src/index.js'], {
cwd: `${stagingPath}/`,
stdio: 'inherit',
});
const options = {
packageDir: process.cwd(), // path to your module.
sample: {
description: 'typescript based used can use my type definitions',
xiaozhenliu-gg5 marked this conversation as resolved.
Show resolved Hide resolved
ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString()
xiaozhenliu-gg5 marked this conversation as resolved.
Show resolved Hide resolved
}
};
await packNTest(options); // will throw upon error.
});

after('cleanup staging', () => {
if (!keep) {
stagingDir.removeCallback();
}
});
});
});
xiaozhenliu-gg5 marked this conversation as resolved.
Show resolved Hide resolved
1 change: 1 addition & 0 deletions typescript/test/testdata/keymanager/package.json.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"mocha": "^6.0.0",
"mv": "^2.1.1",
"ncp": "^2.0.0",
"pack-n-play": "^1.0.0-2",
"tmp": "^0.1.0",
"typescript": "^3.7.0"
},
Expand Down

This file was deleted.

This file was deleted.

45 changes: 13 additions & 32 deletions typescript/test/testdata/keymanager/system-test/install.ts.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -16,40 +16,21 @@
// ** https://github.com/googleapis/gapic-generator-typescript **
// ** All changes to this file may be overwritten. **

import * as execa from 'execa';
import * as mv from 'mv';
import {ncp} from 'ncp';
import * as tmp from 'tmp';
import {promisify} from 'util';
import {packNTest} from 'pack-n-play';
import { readFileSync } from 'fs';

const keep = false;
const mvp = promisify(mv);
const ncpp = promisify(ncp);
const stagingDir = tmp.dirSync({keep, unsafeCleanup: true});
const stagingPath = stagingDir.name;
const pkg = require('../../package.json');
describe('typescript consumer tests', () => {

describe('📦 pack and install', () => {
it('should be able use the library from a TypeScript application', async function() {
it('should have correct type signature for Kms client library', async function() {
this.timeout(300000);
await execa('npm', ['pack', '--unsafe-perm']);
const packageName = pkg.name.replace('@', '').replace('/', '-');
const tarball = `${packageName}-${pkg.version}.tgz`;
await mvp(tarball, `${stagingPath}/kms.tgz`);
await ncpp('system-test/fixtures/sample', `${stagingPath}/`);
await execa('npm', ['install', '--unsafe-perm'], {
cwd: `${stagingPath}/`,
stdio: 'inherit',
});
await execa('node', ['--throw-deprecation', 'build/src/index.js'], {
cwd: `${stagingPath}/`,
stdio: 'inherit',
});
const options = {
packageDir: process.cwd(), // path to your module.
sample: {
description: 'typescript based used can use my type definitions',
ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString()
}
};
await packNTest(options); // will throw upon error.
});

after('cleanup staging', () => {
if (!keep) {
stagingDir.removeCallback();
}
});
});
});
1 change: 1 addition & 0 deletions typescript/test/testdata/showcase/package.json.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"mocha": "^6.0.0",
"mv": "^2.1.1",
"ncp": "^2.0.0",
"pack-n-play": "^1.0.0-2",
"tmp": "^0.1.0",
"typescript": "^3.7.0"
},
Expand Down

This file was deleted.

This file was deleted.

45 changes: 13 additions & 32 deletions typescript/test/testdata/showcase/system-test/install.ts.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -16,40 +16,21 @@
// ** https://github.com/googleapis/gapic-generator-typescript **
// ** All changes to this file may be overwritten. **

import * as execa from 'execa';
import * as mv from 'mv';
import {ncp} from 'ncp';
import * as tmp from 'tmp';
import {promisify} from 'util';
import {packNTest} from 'pack-n-play';
import { readFileSync } from 'fs';

const keep = false;
const mvp = promisify(mv);
const ncpp = promisify(ncp);
const stagingDir = tmp.dirSync({keep, unsafeCleanup: true});
const stagingPath = stagingDir.name;
const pkg = require('../../package.json');
describe('typescript consumer tests', () => {

describe('📦 pack and install', () => {
it('should be able use the library from a TypeScript application', async function() {
it('should have correct type signature for Showcase client library', async function() {
this.timeout(300000);
await execa('npm', ['pack', '--unsafe-perm']);
const packageName = pkg.name.replace('@', '').replace('/', '-');
const tarball = `${packageName}-${pkg.version}.tgz`;
await mvp(tarball, `${stagingPath}/showcase.tgz`);
await ncpp('system-test/fixtures/sample', `${stagingPath}/`);
await execa('npm', ['install', '--unsafe-perm'], {
cwd: `${stagingPath}/`,
stdio: 'inherit',
});
await execa('node', ['--throw-deprecation', 'build/src/index.js'], {
cwd: `${stagingPath}/`,
stdio: 'inherit',
});
const options = {
packageDir: process.cwd(), // path to your module.
sample: {
description: 'typescript based used can use my type definitions',
ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString()
}
};
await packNTest(options); // will throw upon error.
});

after('cleanup staging', () => {
if (!keep) {
stagingDir.removeCallback();
}
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"mocha": "^6.0.0",
"mv": "^2.1.1",
"ncp": "^2.0.0",
"pack-n-play": "^1.0.0-2",
"tmp": "^0.1.0",
"typescript": "^3.7.0"
},
Expand Down

This file was deleted.

This file was deleted.

Loading