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

test: add missing packages and install test #536

Merged
merged 3 commits into from
Mar 8, 2019
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
13 changes: 9 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
"@google-cloud/projectify": "^0.3.0",
"@google-cloud/promisify": "^0.4.0",
"@sindresorhus/is": "^0.15.0",
"@types/duplexify": "^3.6.0",
"@types/p-defer": "^1.0.3",
"arrify": "^1.0.0",
"async-each": "^1.0.1",
"extend": "^3.0.1",
Expand All @@ -71,9 +73,9 @@
"devDependencies": {
"@google-cloud/nodejs-repo-tools": "^3.0.0",
"@types/arrify": "^1.0.4",
"@types/execa": "^0.9.0",
"@types/extend": "^3.0.0",
"@types/mocha": "^5.2.5",
"@types/p-defer": "^1.0.3",
"@types/proxyquire": "^1.3.28",
"@types/sinon": "^7.0.0",
"@types/through2": "^2.0.34",
Expand All @@ -83,11 +85,15 @@
"eslint-config-prettier": "^4.0.0",
"eslint-plugin-node": "^8.0.0",
"eslint-plugin-prettier": "^3.0.0",
"execa": "^1.0.0",
"gts": "^0.9.0",
"jsdoc-baseline": "git+https://github.com/hegemonic/jsdoc-baseline.git",
"intelli-espower-loader": "^1.0.1",
"jsdoc": "^3.5.5",
"jsdoc-baseline": "git+https://github.com/hegemonic/jsdoc-baseline.git",
"linkinator": "^1.1.2",
"mocha": "^6.0.0",
"mv": "^2.1.1",
"ncp": "^2.0.0",
"nyc": "^13.0.0",
"power-assert": "^1.4.4",
"prettier": "^1.9.1",
Expand All @@ -96,7 +102,6 @@
"source-map-support": "^0.5.9",
"through2": "^3.0.0",
"typescript": "~3.3.0",
"uuid": "^3.1.0",
"linkinator": "^1.1.2"
"uuid": "^3.1.0"
}
}
23 changes: 23 additions & 0 deletions system-test/fixtures/sample/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "pubsub-sample-fixture",
"description": "An app we're using to test the library.",
"scripts": {
"check": "gts check",
"clean": "gts clean",
"compile": "tsc -p .",
"fix": "gts fix",
"prepare": "npm run compile",
"pretest": "npm run compile",
"posttest": "npm run check",
"start": "node build/src/index.js"
},
"license": "Apache-2.0",
"dependencies": {
"@google-cloud/pubsub": "file:./pubsub.tgz"
},
"devDependencies": {
"@types/node": "^10.3.0",
"typescript": "^3.0.0",
"gts": "^0.9.0"
}
}
8 changes: 8 additions & 0 deletions system-test/fixtures/sample/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import {PubSub} from '@google-cloud/pubsub';

async function main() {
const pubsub = new PubSub();
console.log(pubsub);
}

main();
12 changes: 12 additions & 0 deletions system-test/fixtures/sample/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "./node_modules/gts/tsconfig-google.json",
"compilerOptions": {
"rootDir": ".",
"outDir": "build",
"types": ["node"],
"skipLibCheck": true,
},
"include": [
"src/*.ts"
]
}
56 changes: 56 additions & 0 deletions system-test/install.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/**
* Copyright 2019 Google LLC. All Rights Reserved.
*
* 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
*
* http://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.
*/

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) as {} as (...args: string[]) => Promise<void>;
const ncpp = promisify(ncp);
const stagingDir = tmp.dirSync({keep, unsafeCleanup: true});
const stagingPath = stagingDir.name;
const pkg = require('../../package.json');

describe('📦 pack and install', () => {
/**
* Create a staging directory with temp fixtures used to test on a fresh
* application.
*/
it('should be able to use the d.ts', async () => {
await execa('npm', ['pack', '--unsafe-perm']);
const tarball = `google-cloud-pubsub-${pkg.version}.tgz`;
await mvp(tarball, `${stagingPath}/pubsub.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'});
});

/**
* CLEAN UP - remove the staging directory when done.
*/
after('cleanup staging', () => {
if (!keep) {
stagingDir.removeCallback();
}
});
});