-
Notifications
You must be signed in to change notification settings - Fork 227
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add missing packages and install test (#536)
- Loading branch information
1 parent
79a842e
commit bd727e1
Showing
5 changed files
with
108 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
}); | ||
}); |