-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: test the typescript install (#183)
- Loading branch information
1 parent
a7c763a
commit a36ee6a
Showing
10 changed files
with
143 additions
and
19 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
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
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,25 @@ | ||
{ | ||
"name": "fixture", | ||
"version": "1.0.0", | ||
"private": true, | ||
"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/common": "file:./google-cloud-common.tgz" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^10.3.0", | ||
"typescript": "^2.9.1", | ||
"gts": "^0.7.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,12 @@ | ||
import {GoogleAuthOptions, Logger, LoggerConfig, CustomLevelsLogger, | ||
CustomLevelsLoggerConfig, logger, Operation, paginator, Paginator, | ||
ParsedArguments, Service, ServiceConfig, ServiceOptions, CreateOptions, | ||
DeleteCallback, ExistsCallback, GetConfig, GetMetadataCallback, | ||
InstanceResponseCallback, Interceptor, Metadata, Methods, ServiceObject, | ||
ServiceObjectConfig, StreamRequestOptions, Abortable, AbortableDuplex, | ||
ApiError, util} from '@google-cloud/common'; | ||
|
||
util.makeRequest({url: 'test'}, (err, body, res) => { | ||
console.log(err); | ||
}); | ||
|
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,10 @@ | ||
{ | ||
"extends": "./node_modules/gts/tsconfig-google.json", | ||
"compilerOptions": { | ||
"rootDir": ".", | ||
"outDir": "build", | ||
"esModuleInterop": false, | ||
"allowSyntheticDefaultImports": false | ||
}, | ||
"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,72 @@ | ||
/** | ||
* Copyright 2018 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 cp from 'child_process'; | ||
import mv from 'mv'; | ||
import {ncp} from 'ncp'; | ||
import os from 'os'; | ||
import pify from 'pify'; | ||
import tmp from 'tmp'; | ||
|
||
const mvp = pify(mv); | ||
const ncpp = pify(ncp); | ||
const keep = !!process.env.KEEP_TEMPDIRS; | ||
const stagingDir = tmp.dirSync({keep, unsafeCleanup: true}); | ||
const stagingPath = stagingDir.name; | ||
const pkg = require('../../package.json'); | ||
const pkgName = 'google-cloud-common'; | ||
const npm = os.platform() === 'win32' ? 'npm.cmd' : 'npm'; | ||
|
||
const spawnp = | ||
(command: string, args: string[], options: cp.SpawnOptions = {}) => { | ||
return new Promise((resolve, reject) => { | ||
cp.spawn(command, args, Object.assign(options, {stdio: 'inherit'})) | ||
.on('close', | ||
code => { | ||
if (code === 0) { | ||
resolve(); | ||
} else { | ||
reject( | ||
new Error(`Spawn failed with an exit code of ${code}`)); | ||
} | ||
}) | ||
.on('error', reject); | ||
}); | ||
}; | ||
|
||
/** | ||
* Create a staging directory with temp fixtures used to test on a fresh | ||
* application. | ||
*/ | ||
it('should be able to use the d.ts', async () => { | ||
console.log(`${__filename} staging area: ${stagingPath}`); | ||
await spawnp(npm, ['pack']); | ||
const tarball = `${pkgName}-${pkg.version}.tgz`; | ||
// stagingPath can be on another filesystem so fs.rename() will fail | ||
// with EXDEV, hence we use `mv` module here. | ||
await mvp(tarball, `${stagingPath}/${pkgName}.tgz`); | ||
await ncpp('test/fixtures/kitchen', `${stagingPath}/`); | ||
await spawnp(npm, ['install'], {cwd: `${stagingPath}/`}); | ||
}).timeout(40000); | ||
|
||
/** | ||
* CLEAN UP - remove the staging directory when done. | ||
*/ | ||
after('cleanup staging', async () => { | ||
if (!keep) { | ||
stagingDir.removeCallback(); | ||
} | ||
}); |
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 |
---|---|---|
|
@@ -12,6 +12,7 @@ | |
"test/**/*.ts" | ||
], | ||
"exclude": [ | ||
"node_modules" | ||
"node_modules", | ||
"test/fixtures" | ||
] | ||
} |