From b9104716a1af137e748da2c43f5f835b2fedf72a Mon Sep 17 00:00:00 2001 From: Alexander Fenster Date: Mon, 11 Nov 2019 09:39:20 -0800 Subject: [PATCH] feat: pack and install test (#121) * feat: pack and install test * circle * improve * gts fix * use gax ^1.9.0 --- .circleci/config.yml | 12 ++-- templates/typescript_gapic/package.json.njk | 16 ++++-- .../system-test/.eslintrc.yml.njk | 22 ++++++++ .../fixtures/sample/package.json.njk | 40 +++++++++++++ .../fixtures/sample/src/index.ts.njk | 31 ++++++++++ .../fixtures/sample/tsconfig.json.njk | 29 ++++++++++ .../system-test/install.ts.njk | 56 +++++++++++++++++++ templates/typescript_gapic/tsconfig.json.njk | 3 +- .../testdata/keymanager/package.json.baseline | 16 ++++-- .../system-test/.eslintrc.yml.baseline | 5 ++ .../fixtures/sample/package.json.baseline | 23 ++++++++ .../fixtures/sample/src/index.ts.baseline | 9 +++ .../fixtures/sample/tsconfig.json.baseline | 14 +++++ .../system-test/install.ts.baseline | 37 ++++++++++++ .../keymanager/tsconfig.json.baseline | 3 +- .../testdata/showcase/package.json.baseline | 16 ++++-- .../system-test/.eslintrc.yml.baseline | 5 ++ .../fixtures/sample/package.json.baseline | 23 ++++++++ .../fixtures/sample/src/index.ts.baseline | 9 +++ .../fixtures/sample/tsconfig.json.baseline | 14 +++++ .../showcase/system-test/install.ts.baseline | 37 ++++++++++++ .../testdata/showcase/tsconfig.json.baseline | 3 +- .../texttospeech/package.json.baseline | 16 ++++-- .../system-test/.eslintrc.yml.baseline | 5 ++ .../fixtures/sample/package.json.baseline | 23 ++++++++ .../fixtures/sample/src/index.ts.baseline | 9 +++ .../fixtures/sample/tsconfig.json.baseline | 14 +++++ .../system-test/install.ts.baseline | 37 ++++++++++++ .../texttospeech/tsconfig.json.baseline | 3 +- .../testdata/translate/package.json.baseline | 16 ++++-- .../system-test/.eslintrc.yml.baseline | 5 ++ .../fixtures/sample/package.json.baseline | 23 ++++++++ .../fixtures/sample/src/index.ts.baseline | 9 +++ .../fixtures/sample/tsconfig.json.baseline | 14 +++++ .../translate/system-test/install.ts.baseline | 37 ++++++++++++ .../testdata/translate/tsconfig.json.baseline | 3 +- 36 files changed, 608 insertions(+), 29 deletions(-) create mode 100644 templates/typescript_gapic/system-test/.eslintrc.yml.njk create mode 100644 templates/typescript_gapic/system-test/fixtures/sample/package.json.njk create mode 100644 templates/typescript_gapic/system-test/fixtures/sample/src/index.ts.njk create mode 100644 templates/typescript_gapic/system-test/fixtures/sample/tsconfig.json.njk create mode 100644 templates/typescript_gapic/system-test/install.ts.njk create mode 100644 typescript/test/testdata/keymanager/system-test/.eslintrc.yml.baseline create mode 100644 typescript/test/testdata/keymanager/system-test/fixtures/sample/package.json.baseline create mode 100644 typescript/test/testdata/keymanager/system-test/fixtures/sample/src/index.ts.baseline create mode 100644 typescript/test/testdata/keymanager/system-test/fixtures/sample/tsconfig.json.baseline create mode 100644 typescript/test/testdata/keymanager/system-test/install.ts.baseline create mode 100644 typescript/test/testdata/showcase/system-test/.eslintrc.yml.baseline create mode 100644 typescript/test/testdata/showcase/system-test/fixtures/sample/package.json.baseline create mode 100644 typescript/test/testdata/showcase/system-test/fixtures/sample/src/index.ts.baseline create mode 100644 typescript/test/testdata/showcase/system-test/fixtures/sample/tsconfig.json.baseline create mode 100644 typescript/test/testdata/showcase/system-test/install.ts.baseline create mode 100644 typescript/test/testdata/texttospeech/system-test/.eslintrc.yml.baseline create mode 100644 typescript/test/testdata/texttospeech/system-test/fixtures/sample/package.json.baseline create mode 100644 typescript/test/testdata/texttospeech/system-test/fixtures/sample/src/index.ts.baseline create mode 100644 typescript/test/testdata/texttospeech/system-test/fixtures/sample/tsconfig.json.baseline create mode 100644 typescript/test/testdata/texttospeech/system-test/install.ts.baseline create mode 100644 typescript/test/testdata/translate/system-test/.eslintrc.yml.baseline create mode 100644 typescript/test/testdata/translate/system-test/fixtures/sample/package.json.baseline create mode 100644 typescript/test/testdata/translate/system-test/fixtures/sample/src/index.ts.baseline create mode 100644 typescript/test/testdata/translate/system-test/fixtures/sample/tsconfig.json.baseline create mode 100644 typescript/test/testdata/translate/system-test/install.ts.baseline diff --git a/.circleci/config.yml b/.circleci/config.yml index 1d7887cb9..8ed987460 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -63,15 +63,16 @@ jobs: npm run browser-test trap stop_showcase EXIT - run: - name: Run unit tests and gts fix of the generated Showcase library + name: Run unit tests, system tests, and gts fix of the generated Showcase library command: | cd .test-out-showcase npm install npm test npm run fix npm run compile + npm run system-test - run: - name: Run unit tests and gts fix of the generated KMS library + name: Run unit tests, system tests, and gts fix of the generated KMS library command: | cp -r typescript/test/protos ./.test-out-keymanager cd .test-out-keymanager @@ -79,8 +80,9 @@ jobs: npm test npm run fix npm run compile + npm run system-test - run: - name: Run unit tests and gts fix of the generated Translate library + name: Run unit tests, system tests, and gts fix of the generated Translate library command: | cp -r typescript/test/protos ./.test-out-translate cd .test-out-translate @@ -88,8 +90,9 @@ jobs: npm test npm run fix npm run compile + npm run system-test - run: - name: Run unit tests and gts fix of the generated Text-to-Speech library + name: Run unit tests, system tests, and gts fix of the generated Text-to-Speech library command: | cp -r typescript/test/protos ./.test-out-texttospeech cd .test-out-texttospeech @@ -97,6 +100,7 @@ jobs: npm test npm run fix npm run compile + npm run system-test - run: name: Run linting command: | diff --git a/templates/typescript_gapic/package.json.njk b/templates/typescript_gapic/package.json.njk index 8c8f34937..bb6f6480e 100644 --- a/templates/typescript_gapic/package.json.njk +++ b/templates/typescript_gapic/package.json.njk @@ -27,14 +27,21 @@ limitations under the License. "build/protos" ], "dependencies": { - "google-gax": "^1.8.0" + "google-gax": "^1.9.0" }, "devDependencies": { - "@types/node": "^12.0.0", "@types/mocha": "^5.2.5", + "@types/mv": "^2.1.0", + "@types/ncp": "^2.0.3", + "@types/node": "^12.0.0", + "@types/tmp": "^0.1.0", + "execa": "^3.2.0", "gts": "^1.0.0", "mocha": "^6.0.0", - "typescript": "~3.6.0" + "mv": "^2.1.1", + "ncp": "^2.0.0", + "tmp": "^0.1.0", + "typescript": "^3.7.0" }, "scripts": { "lint": "gts check", @@ -43,7 +50,8 @@ limitations under the License. "compile-protos": "compileProtos src", "fix": "gts fix", "prepare": "npm run compile-protos && npm run compile", - "test": "mocha build/test" + "test": "mocha build/test", + "system-test": "mocha build/system-test" }, "license": "Apache-2.0", "engines": { diff --git a/templates/typescript_gapic/system-test/.eslintrc.yml.njk b/templates/typescript_gapic/system-test/.eslintrc.yml.njk new file mode 100644 index 000000000..8553d5024 --- /dev/null +++ b/templates/typescript_gapic/system-test/.eslintrc.yml.njk @@ -0,0 +1,22 @@ +{#- + +Copyright 2019 Google LLC + +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. + +-#} +--- +env: + mocha: true +rules: + no-console: off diff --git a/templates/typescript_gapic/system-test/fixtures/sample/package.json.njk b/templates/typescript_gapic/system-test/fixtures/sample/package.json.njk new file mode 100644 index 000000000..255a2320c --- /dev/null +++ b/templates/typescript_gapic/system-test/fixtures/sample/package.json.njk @@ -0,0 +1,40 @@ +{#- + +Copyright 2019 Google LLC + +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. + +-#} +{ + "name": "{{ api.naming.productName.toKebabCase() }}-sample-fixture", + "description": "An app we're using to test the {{ api.naming.productName }} 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": { + "{{ api.naming.productName.toKebabCase() }}": "file:./{{ api.naming.productName.toKebabCase() }}.tgz" + }, + "devDependencies": { + "@types/node": "^12.0.0", + "typescript": "^3.0.0", + "gts": "^1.0.0" + } +} diff --git a/templates/typescript_gapic/system-test/fixtures/sample/src/index.ts.njk b/templates/typescript_gapic/system-test/fixtures/sample/src/index.ts.njk new file mode 100644 index 000000000..7a612e961 --- /dev/null +++ b/templates/typescript_gapic/system-test/fixtures/sample/src/index.ts.njk @@ -0,0 +1,31 @@ +{#- + +Copyright 2019 Google LLC + +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 "../../../../_license.njk" as license -%} + +{%- for service in api.services %} +import { {{- service.name.toPascalCase() + 'Client' -}} } from '{{ api.naming.productName.toKebabCase() }}'; +{%- endfor %} + +function main() { +{%- for service in api.services %} + const {{ service.name.toCamelCase() -}}Client = new {{ service.name.toPascalCase() + 'Client' -}}(); + console.log("{{- service.name.toCamelCase() -}}Client was created!"); +{%- endfor %} +} + +main(); diff --git a/templates/typescript_gapic/system-test/fixtures/sample/tsconfig.json.njk b/templates/typescript_gapic/system-test/fixtures/sample/tsconfig.json.njk new file mode 100644 index 000000000..7c8bc7157 --- /dev/null +++ b/templates/typescript_gapic/system-test/fixtures/sample/tsconfig.json.njk @@ -0,0 +1,29 @@ +{#- + +Copyright 2019 Google LLC + +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. + +-#} +{ + "extends": "./node_modules/gts/tsconfig-google.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "build", + "types": ["node"], + "skipLibCheck": false + }, + "include": [ + "src/*.ts" + ] +} diff --git a/templates/typescript_gapic/system-test/install.ts.njk b/templates/typescript_gapic/system-test/install.ts.njk new file mode 100644 index 000000000..652f282a3 --- /dev/null +++ b/templates/typescript_gapic/system-test/install.ts.njk @@ -0,0 +1,56 @@ +{#- + +Copyright 2019 Google LLC + +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 "../_license.njk" as 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() { + 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', + }); + }); + + after('cleanup staging', () => { + if (!keep) { + stagingDir.removeCallback(); + } + }); +}); diff --git a/templates/typescript_gapic/tsconfig.json.njk b/templates/typescript_gapic/tsconfig.json.njk index 6d41173c7..bfd1a4c5b 100644 --- a/templates/typescript_gapic/tsconfig.json.njk +++ b/templates/typescript_gapic/tsconfig.json.njk @@ -27,6 +27,7 @@ limitations under the License. "src/*.ts", "src/**/*.ts", "test/*.ts", - "test/**/*.ts" + "test/**/*.ts", + "system-test/*.ts" ] } diff --git a/typescript/test/testdata/keymanager/package.json.baseline b/typescript/test/testdata/keymanager/package.json.baseline index 582197081..6efdd7e3f 100644 --- a/typescript/test/testdata/keymanager/package.json.baseline +++ b/typescript/test/testdata/keymanager/package.json.baseline @@ -10,14 +10,21 @@ "build/protos" ], "dependencies": { - "google-gax": "^1.8.0" + "google-gax": "^1.9.0" }, "devDependencies": { - "@types/node": "^12.0.0", "@types/mocha": "^5.2.5", + "@types/mv": "^2.1.0", + "@types/ncp": "^2.0.3", + "@types/node": "^12.0.0", + "@types/tmp": "^0.1.0", + "execa": "^3.2.0", "gts": "^1.0.0", "mocha": "^6.0.0", - "typescript": "~3.6.0" + "mv": "^2.1.1", + "ncp": "^2.0.0", + "tmp": "^0.1.0", + "typescript": "^3.7.0" }, "scripts": { "lint": "gts check", @@ -26,7 +33,8 @@ "compile-protos": "compileProtos src", "fix": "gts fix", "prepare": "npm run compile-protos && npm run compile", - "test": "mocha build/test" + "test": "mocha build/test", + "system-test": "mocha build/system-test" }, "license": "Apache-2.0", "engines": { diff --git a/typescript/test/testdata/keymanager/system-test/.eslintrc.yml.baseline b/typescript/test/testdata/keymanager/system-test/.eslintrc.yml.baseline new file mode 100644 index 000000000..f9605165c --- /dev/null +++ b/typescript/test/testdata/keymanager/system-test/.eslintrc.yml.baseline @@ -0,0 +1,5 @@ +--- +env: + mocha: true +rules: + no-console: off diff --git a/typescript/test/testdata/keymanager/system-test/fixtures/sample/package.json.baseline b/typescript/test/testdata/keymanager/system-test/fixtures/sample/package.json.baseline new file mode 100644 index 000000000..4a4e1febb --- /dev/null +++ b/typescript/test/testdata/keymanager/system-test/fixtures/sample/package.json.baseline @@ -0,0 +1,23 @@ +{ + "name": "kms-sample-fixture", + "description": "An app we're using to test the Kms 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": { + "kms": "file:./kms.tgz" + }, + "devDependencies": { + "@types/node": "^12.0.0", + "typescript": "^3.0.0", + "gts": "^1.0.0" + } +} diff --git a/typescript/test/testdata/keymanager/system-test/fixtures/sample/src/index.ts.baseline b/typescript/test/testdata/keymanager/system-test/fixtures/sample/src/index.ts.baseline new file mode 100644 index 000000000..42f83dae5 --- /dev/null +++ b/typescript/test/testdata/keymanager/system-test/fixtures/sample/src/index.ts.baseline @@ -0,0 +1,9 @@ + +import {KeyManagementServiceClient} from 'kms'; + +function main() { + const keyManagementServiceClient = new KeyManagementServiceClient(); + console.log("keyManagementServiceClient was created!"); +} + +main(); diff --git a/typescript/test/testdata/keymanager/system-test/fixtures/sample/tsconfig.json.baseline b/typescript/test/testdata/keymanager/system-test/fixtures/sample/tsconfig.json.baseline new file mode 100644 index 000000000..e5f760d87 --- /dev/null +++ b/typescript/test/testdata/keymanager/system-test/fixtures/sample/tsconfig.json.baseline @@ -0,0 +1,14 @@ +{ + "extends": "./node_modules/gts/tsconfig-google.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "build", + "types": [ + "node" + ], + "skipLibCheck": false + }, + "include": [ + "src/*.ts" + ] +} diff --git a/typescript/test/testdata/keymanager/system-test/install.ts.baseline b/typescript/test/testdata/keymanager/system-test/install.ts.baseline new file mode 100644 index 000000000..d22d1ba8b --- /dev/null +++ b/typescript/test/testdata/keymanager/system-test/install.ts.baseline @@ -0,0 +1,37 @@ +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() { + 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', + }); + }); + + after('cleanup staging', () => { + if (!keep) { + stagingDir.removeCallback(); + } + }); +}); diff --git a/typescript/test/testdata/keymanager/tsconfig.json.baseline b/typescript/test/testdata/keymanager/tsconfig.json.baseline index 653c21079..613d35597 100644 --- a/typescript/test/testdata/keymanager/tsconfig.json.baseline +++ b/typescript/test/testdata/keymanager/tsconfig.json.baseline @@ -13,6 +13,7 @@ "src/*.ts", "src/**/*.ts", "test/*.ts", - "test/**/*.ts" + "test/**/*.ts", + "system-test/*.ts" ] } diff --git a/typescript/test/testdata/showcase/package.json.baseline b/typescript/test/testdata/showcase/package.json.baseline index caf7afedd..5d690961e 100644 --- a/typescript/test/testdata/showcase/package.json.baseline +++ b/typescript/test/testdata/showcase/package.json.baseline @@ -10,14 +10,21 @@ "build/protos" ], "dependencies": { - "google-gax": "^1.8.0" + "google-gax": "^1.9.0" }, "devDependencies": { - "@types/node": "^12.0.0", "@types/mocha": "^5.2.5", + "@types/mv": "^2.1.0", + "@types/ncp": "^2.0.3", + "@types/node": "^12.0.0", + "@types/tmp": "^0.1.0", + "execa": "^3.2.0", "gts": "^1.0.0", "mocha": "^6.0.0", - "typescript": "~3.6.0" + "mv": "^2.1.1", + "ncp": "^2.0.0", + "tmp": "^0.1.0", + "typescript": "^3.7.0" }, "scripts": { "lint": "gts check", @@ -26,7 +33,8 @@ "compile-protos": "compileProtos src", "fix": "gts fix", "prepare": "npm run compile-protos && npm run compile", - "test": "mocha build/test" + "test": "mocha build/test", + "system-test": "mocha build/system-test" }, "license": "Apache-2.0", "engines": { diff --git a/typescript/test/testdata/showcase/system-test/.eslintrc.yml.baseline b/typescript/test/testdata/showcase/system-test/.eslintrc.yml.baseline new file mode 100644 index 000000000..f9605165c --- /dev/null +++ b/typescript/test/testdata/showcase/system-test/.eslintrc.yml.baseline @@ -0,0 +1,5 @@ +--- +env: + mocha: true +rules: + no-console: off diff --git a/typescript/test/testdata/showcase/system-test/fixtures/sample/package.json.baseline b/typescript/test/testdata/showcase/system-test/fixtures/sample/package.json.baseline new file mode 100644 index 000000000..e4325fb93 --- /dev/null +++ b/typescript/test/testdata/showcase/system-test/fixtures/sample/package.json.baseline @@ -0,0 +1,23 @@ +{ + "name": "showcase-sample-fixture", + "description": "An app we're using to test the Showcase 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": { + "showcase": "file:./showcase.tgz" + }, + "devDependencies": { + "@types/node": "^12.0.0", + "typescript": "^3.0.0", + "gts": "^1.0.0" + } +} diff --git a/typescript/test/testdata/showcase/system-test/fixtures/sample/src/index.ts.baseline b/typescript/test/testdata/showcase/system-test/fixtures/sample/src/index.ts.baseline new file mode 100644 index 000000000..1c6351aa6 --- /dev/null +++ b/typescript/test/testdata/showcase/system-test/fixtures/sample/src/index.ts.baseline @@ -0,0 +1,9 @@ + +import {EchoClient} from 'showcase'; + +function main() { + const echoClient = new EchoClient(); + console.log("echoClient was created!"); +} + +main(); diff --git a/typescript/test/testdata/showcase/system-test/fixtures/sample/tsconfig.json.baseline b/typescript/test/testdata/showcase/system-test/fixtures/sample/tsconfig.json.baseline new file mode 100644 index 000000000..e5f760d87 --- /dev/null +++ b/typescript/test/testdata/showcase/system-test/fixtures/sample/tsconfig.json.baseline @@ -0,0 +1,14 @@ +{ + "extends": "./node_modules/gts/tsconfig-google.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "build", + "types": [ + "node" + ], + "skipLibCheck": false + }, + "include": [ + "src/*.ts" + ] +} diff --git a/typescript/test/testdata/showcase/system-test/install.ts.baseline b/typescript/test/testdata/showcase/system-test/install.ts.baseline new file mode 100644 index 000000000..0136cf7f3 --- /dev/null +++ b/typescript/test/testdata/showcase/system-test/install.ts.baseline @@ -0,0 +1,37 @@ +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() { + 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', + }); + }); + + after('cleanup staging', () => { + if (!keep) { + stagingDir.removeCallback(); + } + }); +}); diff --git a/typescript/test/testdata/showcase/tsconfig.json.baseline b/typescript/test/testdata/showcase/tsconfig.json.baseline index 653c21079..613d35597 100644 --- a/typescript/test/testdata/showcase/tsconfig.json.baseline +++ b/typescript/test/testdata/showcase/tsconfig.json.baseline @@ -13,6 +13,7 @@ "src/*.ts", "src/**/*.ts", "test/*.ts", - "test/**/*.ts" + "test/**/*.ts", + "system-test/*.ts" ] } diff --git a/typescript/test/testdata/texttospeech/package.json.baseline b/typescript/test/testdata/texttospeech/package.json.baseline index f30c2517d..84e222e36 100644 --- a/typescript/test/testdata/texttospeech/package.json.baseline +++ b/typescript/test/testdata/texttospeech/package.json.baseline @@ -10,14 +10,21 @@ "build/protos" ], "dependencies": { - "google-gax": "^1.8.0" + "google-gax": "^1.9.0" }, "devDependencies": { - "@types/node": "^12.0.0", "@types/mocha": "^5.2.5", + "@types/mv": "^2.1.0", + "@types/ncp": "^2.0.3", + "@types/node": "^12.0.0", + "@types/tmp": "^0.1.0", + "execa": "^3.2.0", "gts": "^1.0.0", "mocha": "^6.0.0", - "typescript": "~3.6.0" + "mv": "^2.1.1", + "ncp": "^2.0.0", + "tmp": "^0.1.0", + "typescript": "^3.7.0" }, "scripts": { "lint": "gts check", @@ -26,7 +33,8 @@ "compile-protos": "compileProtos src", "fix": "gts fix", "prepare": "npm run compile-protos && npm run compile", - "test": "mocha build/test" + "test": "mocha build/test", + "system-test": "mocha build/system-test" }, "license": "Apache-2.0", "engines": { diff --git a/typescript/test/testdata/texttospeech/system-test/.eslintrc.yml.baseline b/typescript/test/testdata/texttospeech/system-test/.eslintrc.yml.baseline new file mode 100644 index 000000000..f9605165c --- /dev/null +++ b/typescript/test/testdata/texttospeech/system-test/.eslintrc.yml.baseline @@ -0,0 +1,5 @@ +--- +env: + mocha: true +rules: + no-console: off diff --git a/typescript/test/testdata/texttospeech/system-test/fixtures/sample/package.json.baseline b/typescript/test/testdata/texttospeech/system-test/fixtures/sample/package.json.baseline new file mode 100644 index 000000000..71b238658 --- /dev/null +++ b/typescript/test/testdata/texttospeech/system-test/fixtures/sample/package.json.baseline @@ -0,0 +1,23 @@ +{ + "name": "texttospeech-sample-fixture", + "description": "An app we're using to test the Texttospeech 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": { + "texttospeech": "file:./texttospeech.tgz" + }, + "devDependencies": { + "@types/node": "^12.0.0", + "typescript": "^3.0.0", + "gts": "^1.0.0" + } +} diff --git a/typescript/test/testdata/texttospeech/system-test/fixtures/sample/src/index.ts.baseline b/typescript/test/testdata/texttospeech/system-test/fixtures/sample/src/index.ts.baseline new file mode 100644 index 000000000..95c20e58b --- /dev/null +++ b/typescript/test/testdata/texttospeech/system-test/fixtures/sample/src/index.ts.baseline @@ -0,0 +1,9 @@ + +import {TextToSpeechClient} from 'texttospeech'; + +function main() { + const textToSpeechClient = new TextToSpeechClient(); + console.log("textToSpeechClient was created!"); +} + +main(); diff --git a/typescript/test/testdata/texttospeech/system-test/fixtures/sample/tsconfig.json.baseline b/typescript/test/testdata/texttospeech/system-test/fixtures/sample/tsconfig.json.baseline new file mode 100644 index 000000000..e5f760d87 --- /dev/null +++ b/typescript/test/testdata/texttospeech/system-test/fixtures/sample/tsconfig.json.baseline @@ -0,0 +1,14 @@ +{ + "extends": "./node_modules/gts/tsconfig-google.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "build", + "types": [ + "node" + ], + "skipLibCheck": false + }, + "include": [ + "src/*.ts" + ] +} diff --git a/typescript/test/testdata/texttospeech/system-test/install.ts.baseline b/typescript/test/testdata/texttospeech/system-test/install.ts.baseline new file mode 100644 index 000000000..6e16e6140 --- /dev/null +++ b/typescript/test/testdata/texttospeech/system-test/install.ts.baseline @@ -0,0 +1,37 @@ +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() { + 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}/texttospeech.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', + }); + }); + + after('cleanup staging', () => { + if (!keep) { + stagingDir.removeCallback(); + } + }); +}); diff --git a/typescript/test/testdata/texttospeech/tsconfig.json.baseline b/typescript/test/testdata/texttospeech/tsconfig.json.baseline index 653c21079..613d35597 100644 --- a/typescript/test/testdata/texttospeech/tsconfig.json.baseline +++ b/typescript/test/testdata/texttospeech/tsconfig.json.baseline @@ -13,6 +13,7 @@ "src/*.ts", "src/**/*.ts", "test/*.ts", - "test/**/*.ts" + "test/**/*.ts", + "system-test/*.ts" ] } diff --git a/typescript/test/testdata/translate/package.json.baseline b/typescript/test/testdata/translate/package.json.baseline index 653ffe9c3..c34b51122 100644 --- a/typescript/test/testdata/translate/package.json.baseline +++ b/typescript/test/testdata/translate/package.json.baseline @@ -10,14 +10,21 @@ "build/protos" ], "dependencies": { - "google-gax": "^1.8.0" + "google-gax": "^1.9.0" }, "devDependencies": { - "@types/node": "^12.0.0", "@types/mocha": "^5.2.5", + "@types/mv": "^2.1.0", + "@types/ncp": "^2.0.3", + "@types/node": "^12.0.0", + "@types/tmp": "^0.1.0", + "execa": "^3.2.0", "gts": "^1.0.0", "mocha": "^6.0.0", - "typescript": "~3.6.0" + "mv": "^2.1.1", + "ncp": "^2.0.0", + "tmp": "^0.1.0", + "typescript": "^3.7.0" }, "scripts": { "lint": "gts check", @@ -26,7 +33,8 @@ "compile-protos": "compileProtos src", "fix": "gts fix", "prepare": "npm run compile-protos && npm run compile", - "test": "mocha build/test" + "test": "mocha build/test", + "system-test": "mocha build/system-test" }, "license": "Apache-2.0", "engines": { diff --git a/typescript/test/testdata/translate/system-test/.eslintrc.yml.baseline b/typescript/test/testdata/translate/system-test/.eslintrc.yml.baseline new file mode 100644 index 000000000..f9605165c --- /dev/null +++ b/typescript/test/testdata/translate/system-test/.eslintrc.yml.baseline @@ -0,0 +1,5 @@ +--- +env: + mocha: true +rules: + no-console: off diff --git a/typescript/test/testdata/translate/system-test/fixtures/sample/package.json.baseline b/typescript/test/testdata/translate/system-test/fixtures/sample/package.json.baseline new file mode 100644 index 000000000..f4c9f96d7 --- /dev/null +++ b/typescript/test/testdata/translate/system-test/fixtures/sample/package.json.baseline @@ -0,0 +1,23 @@ +{ + "name": "translation-sample-fixture", + "description": "An app we're using to test the Translation 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": { + "translation": "file:./translation.tgz" + }, + "devDependencies": { + "@types/node": "^12.0.0", + "typescript": "^3.0.0", + "gts": "^1.0.0" + } +} diff --git a/typescript/test/testdata/translate/system-test/fixtures/sample/src/index.ts.baseline b/typescript/test/testdata/translate/system-test/fixtures/sample/src/index.ts.baseline new file mode 100644 index 000000000..6f7cf0ad9 --- /dev/null +++ b/typescript/test/testdata/translate/system-test/fixtures/sample/src/index.ts.baseline @@ -0,0 +1,9 @@ + +import {TranslationServiceClient} from 'translation'; + +function main() { + const translationServiceClient = new TranslationServiceClient(); + console.log("translationServiceClient was created!"); +} + +main(); diff --git a/typescript/test/testdata/translate/system-test/fixtures/sample/tsconfig.json.baseline b/typescript/test/testdata/translate/system-test/fixtures/sample/tsconfig.json.baseline new file mode 100644 index 000000000..e5f760d87 --- /dev/null +++ b/typescript/test/testdata/translate/system-test/fixtures/sample/tsconfig.json.baseline @@ -0,0 +1,14 @@ +{ + "extends": "./node_modules/gts/tsconfig-google.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "build", + "types": [ + "node" + ], + "skipLibCheck": false + }, + "include": [ + "src/*.ts" + ] +} diff --git a/typescript/test/testdata/translate/system-test/install.ts.baseline b/typescript/test/testdata/translate/system-test/install.ts.baseline new file mode 100644 index 000000000..25e6573c9 --- /dev/null +++ b/typescript/test/testdata/translate/system-test/install.ts.baseline @@ -0,0 +1,37 @@ +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() { + 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}/translation.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', + }); + }); + + after('cleanup staging', () => { + if (!keep) { + stagingDir.removeCallback(); + } + }); +}); diff --git a/typescript/test/testdata/translate/tsconfig.json.baseline b/typescript/test/testdata/translate/tsconfig.json.baseline index 653c21079..613d35597 100644 --- a/typescript/test/testdata/translate/tsconfig.json.baseline +++ b/typescript/test/testdata/translate/tsconfig.json.baseline @@ -13,6 +13,7 @@ "src/*.ts", "src/**/*.ts", "test/*.ts", - "test/**/*.ts" + "test/**/*.ts", + "system-test/*.ts" ] }