Skip to content

Commit 6844e43

Browse files
jiacfanvinjiang
authored andcommitted
[Storage](File) Optimize one test case to additionally validate new properties returned during download file.
1 parent 3cda16f commit 6844e43

File tree

2 files changed

+92
-0
lines changed

2 files changed

+92
-0
lines changed

sdk/storage/storage-file/src/FileDownloadResponse.ts

+77
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,83 @@ export class FileDownloadResponse implements Models.FileDownloadResponse {
325325
return this.originalResponse.version;
326326
}
327327

328+
/**
329+
* Attributes set for the file.
330+
*
331+
* @readonly
332+
* @type {(string | undefined)}
333+
* @memberof FileDownloadResponse
334+
*/
335+
public get fileAttributes(): string | undefined {
336+
return this.originalResponse.fileAttributes;
337+
}
338+
339+
/**
340+
* Creation time for the file.
341+
*
342+
* @readonly
343+
* @type {(Date | undefined)}
344+
* @memberof FileDownloadResponse
345+
*/
346+
public get fileCreationTime(): Date | undefined {
347+
return this.originalResponse.fileCreationTime;
348+
}
349+
350+
/**
351+
* Last write time for the file.
352+
*
353+
* @readonly
354+
* @type {(string | undefined)}
355+
* @memberof FileDownloadResponse
356+
*/
357+
public get fileLastWriteTime(): Date | undefined {
358+
return this.originalResponse.fileLastWriteTime;
359+
}
360+
361+
/**
362+
* Change time for the file.
363+
*
364+
* @readonly
365+
* @type {(string | undefined)}
366+
* @memberof FileDownloadResponse
367+
*/
368+
public get fileChangeTime(): Date | undefined {
369+
return this.originalResponse.fileChangeTime;
370+
}
371+
372+
/**
373+
* Key of the permission set for the file.
374+
*
375+
* @readonly
376+
* @type {(string | undefined)}
377+
* @memberof FileDownloadResponse
378+
*/
379+
public get filePermissionKey(): string | undefined {
380+
return this.originalResponse.filePermissionKey;
381+
}
382+
383+
/**
384+
* The fileId of the file.
385+
*
386+
* @readonly
387+
* @type {(string | undefined)}
388+
* @memberof FileDownloadResponse
389+
*/
390+
public get fileId(): string | undefined {
391+
return this.originalResponse.fileId;
392+
}
393+
394+
/**
395+
* The parent fileId of the file.
396+
*
397+
* @readonly
398+
* @type {(string | undefined)}
399+
* @memberof FileDownloadResponse
400+
*/
401+
public get fileParentId(): string | undefined {
402+
return this.originalResponse.fileParentId;
403+
}
404+
328405
/**
329406
* The response body as a browser Blob.
330407
* Always undefined in node.js.

sdk/storage/storage-file/test/fileurl.spec.ts

+15
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,21 @@ describe("FileURL", () => {
9999

100100
const result = await fileURL.download(Aborter.none, 0);
101101
assert.deepStrictEqual(await bodyToString(result, 512), "\u0000".repeat(512));
102+
const respFileAttributesFromDownload = FileSystemAttributes.parse(result.fileAttributes!);
103+
assert.ok(respFileAttributesFromDownload.readonly);
104+
assert.ok(respFileAttributesFromDownload.hidden);
105+
assert.ok(respFileAttributesFromDownload.system);
106+
assert.ok(respFileAttributesFromDownload.archive);
107+
assert.ok(respFileAttributesFromDownload.offline);
108+
assert.ok(respFileAttributesFromDownload.notContentIndexed);
109+
assert.ok(respFileAttributesFromDownload.noScrubData);
110+
assert.ok(respFileAttributesFromDownload.temporary);
111+
assert.equal(truncatedISO8061Date(result.fileCreationTime!), truncatedISO8061Date(now));
112+
assert.equal(truncatedISO8061Date(result.fileLastWriteTime!), truncatedISO8061Date(now));
113+
assert.equal(result.filePermissionKey!, defaultDirCreateResp.filePermissionKey!);
114+
assert.ok(result.fileChangeTime!);
115+
assert.ok(result.fileId!);
116+
assert.ok(result.fileParentId!);
102117

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

0 commit comments

Comments
 (0)