Skip to content

Commit

Permalink
[Storage](File) Optimize one test case to additionally validate new p…
Browse files Browse the repository at this point in the history
…roperties returned during download file.
  • Loading branch information
jiacfan authored and vinjiang committed Sep 9, 2019
1 parent 3cda16f commit 6844e43
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 0 deletions.
77 changes: 77 additions & 0 deletions sdk/storage/storage-file/src/FileDownloadResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,83 @@ export class FileDownloadResponse implements Models.FileDownloadResponse {
return this.originalResponse.version;
}

/**
* Attributes set for the file.
*
* @readonly
* @type {(string | undefined)}
* @memberof FileDownloadResponse
*/
public get fileAttributes(): string | undefined {
return this.originalResponse.fileAttributes;
}

/**
* Creation time for the file.
*
* @readonly
* @type {(Date | undefined)}
* @memberof FileDownloadResponse
*/
public get fileCreationTime(): Date | undefined {
return this.originalResponse.fileCreationTime;
}

/**
* Last write time for the file.
*
* @readonly
* @type {(string | undefined)}
* @memberof FileDownloadResponse
*/
public get fileLastWriteTime(): Date | undefined {
return this.originalResponse.fileLastWriteTime;
}

/**
* Change time for the file.
*
* @readonly
* @type {(string | undefined)}
* @memberof FileDownloadResponse
*/
public get fileChangeTime(): Date | undefined {
return this.originalResponse.fileChangeTime;
}

/**
* Key of the permission set for the file.
*
* @readonly
* @type {(string | undefined)}
* @memberof FileDownloadResponse
*/
public get filePermissionKey(): string | undefined {
return this.originalResponse.filePermissionKey;
}

/**
* The fileId of the file.
*
* @readonly
* @type {(string | undefined)}
* @memberof FileDownloadResponse
*/
public get fileId(): string | undefined {
return this.originalResponse.fileId;
}

/**
* The parent fileId of the file.
*
* @readonly
* @type {(string | undefined)}
* @memberof FileDownloadResponse
*/
public get fileParentId(): string | undefined {
return this.originalResponse.fileParentId;
}

/**
* The response body as a browser Blob.
* Always undefined in node.js.
Expand Down
15 changes: 15 additions & 0 deletions sdk/storage/storage-file/test/fileurl.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,21 @@ describe("FileURL", () => {

const result = await fileURL.download(Aborter.none, 0);
assert.deepStrictEqual(await bodyToString(result, 512), "\u0000".repeat(512));
const respFileAttributesFromDownload = FileSystemAttributes.parse(result.fileAttributes!);
assert.ok(respFileAttributesFromDownload.readonly);
assert.ok(respFileAttributesFromDownload.hidden);
assert.ok(respFileAttributesFromDownload.system);
assert.ok(respFileAttributesFromDownload.archive);
assert.ok(respFileAttributesFromDownload.offline);
assert.ok(respFileAttributesFromDownload.notContentIndexed);
assert.ok(respFileAttributesFromDownload.noScrubData);
assert.ok(respFileAttributesFromDownload.temporary);
assert.equal(truncatedISO8061Date(result.fileCreationTime!), truncatedISO8061Date(now));
assert.equal(truncatedISO8061Date(result.fileLastWriteTime!), truncatedISO8061Date(now));
assert.equal(result.filePermissionKey!, defaultDirCreateResp.filePermissionKey!);
assert.ok(result.fileChangeTime!);
assert.ok(result.fileId!);
assert.ok(result.fileParentId!);

const properties = await fileURL.getProperties(Aborter.none);
assert.equal(properties.cacheControl, options.fileHTTPHeaders.fileCacheControl);
Expand Down

0 comments on commit 6844e43

Please sign in to comment.