Skip to content

Commit

Permalink
add axios
Browse files Browse the repository at this point in the history
  • Loading branch information
kjin committed Mar 22, 2018
1 parent 45a22ed commit d8b553f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 18 deletions.
15 changes: 0 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
"pify": "^3.0.0",
"proxyquire": "^1.4.0",
"request": "^2.83.0",
"retry-axios": "^0.3.2",
"rimraf": "^2.6.2",
"source-map-support": "^0.5.0",
"standard-version": "^4.2.0",
Expand Down
19 changes: 16 additions & 3 deletions test/nocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,34 @@ export function oauth2<T extends {} = {}>(validator?: (body: T) => boolean):
});
}

export function projectId(reply: () => string) {
export function projectId(status: number|(() => string), reply?: () => string) {
if (typeof status === 'function') {
reply = status;
status = 200;
}
return nock('http://metadata.google.internal')
.get('/computeMetadata/v1/project/project-id')
.once()
.reply(200, reply, {'Metadata-Flavor': 'Google'});
}

export function instanceId(reply: () => string) {
export function instanceId(
status: number|(() => string), reply?: () => string) {
if (typeof status === 'function') {
reply = status;
status = 200;
}
return nock('http://metadata.google.internal')
.get('/computeMetadata/v1/instance/id')
.once()
.reply(200, reply, {'Metadata-Flavor': 'Google'});
}

export function hostname(reply: () => string) {
export function hostname(status: number|(() => string), reply?: () => string) {
if (typeof status === 'function') {
reply = status;
status = 200;
}
return nock('http://metadata.google.internal')
.get('/computeMetadata/v1/instance/hostname')
.once()
Expand Down

0 comments on commit d8b553f

Please sign in to comment.