Skip to content

Commit

Permalink
test: fix types in signer test for typescript update (googleapis#1904)
Browse files Browse the repository at this point in the history
  • Loading branch information
ddelgrosso1 committed May 23, 2022
1 parent 0c9485d commit 67ac7f8
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions test/signer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,17 @@ import {
} from '../src/signer';
import {encodeURI, formatAsUTCISO, qsStringify} from '../src/util';
import {ExceptionMessages} from '../src/storage';
import {OutgoingHttpHeaders} from 'http';

interface SignedUrlArgs {
bucket: string;
method: 'GET' | 'POST' | 'PUT' | 'DELETE';
contentMd5?: string;
contentType?: string;
extensionHeaders?: OutgoingHttpHeaders;
expiration?: number;
file: string;
}

describe('signer', () => {
const BUCKET_NAME = 'bucket-name';
Expand Down Expand Up @@ -119,7 +130,7 @@ describe('signer', () => {

await signer.getSignedUrl(CONFIG);
assert(v2.calledOnce);
const v2arg = v2.getCall(0).args[0];
const v2arg = v2.getCall(0).args[0] as SignedUrlArgs;
assert.strictEqual(v2arg.bucket, bucket.name);
assert.strictEqual(v2arg.method, CONFIG.method);
assert.strictEqual(v2arg.contentMd5, CONFIG.contentMd5);
Expand Down Expand Up @@ -147,7 +158,7 @@ describe('signer', () => {

await signer.getSignedUrl(CONFIG);
assert(v4.calledOnce);
const v4arg = v4.getCall(0).args[0];
const v4arg = v4.getCall(0).args[0] as SignedUrlArgs;
assert.strictEqual(v4arg.bucket, bucket.name);
assert.strictEqual(v4arg.method, CONFIG.method);
assert.strictEqual(v4arg.contentMd5, CONFIG.contentMd5);
Expand Down Expand Up @@ -273,7 +284,10 @@ describe('signer', () => {
assert(parseExpires.calledOnceWith(CONFIG.expires));
const expiresInSeconds = parseExpires.getCall(0).lastArg;

assert(v2.getCall(0).args[0].expiration, expiresInSeconds);
assert(
(v2.getCall(0).args[0] as SignedUrlArgs).expiration,
expiresInSeconds
);
});
});

Expand Down Expand Up @@ -369,7 +383,7 @@ describe('signer', () => {
.resolves({});

await signer.getSignedUrl(CONFIG);
const v2arg = v2.getCall(0).args[0];
const v2arg = v2.getCall(0).args[0] as SignedUrlArgs;
assert.strictEqual(v2arg.file, encoded);
assert(signedUrl.includes(encoded));
});
Expand Down

0 comments on commit 67ac7f8

Please sign in to comment.