Skip to content

Commit 52fb456

Browse files
authored
Fix test case failures. (Azure#19511)
1 parent 2602e2f commit 52fb456

File tree

11 files changed

+61
-62
lines changed

11 files changed

+61
-62
lines changed

sdk/storage/storage-file-datalake/test/browser/highlevel.browser.spec.ts

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -152,29 +152,28 @@ describe("Highlevel browser only", () => {
152152
uint8Array[i] = i;
153153
}
154154

155-
const blob = new Blob([arrayBuf], { type: "text/plain;charset=utf-8" });
155+
const blob = new Blob([arrayBuf]);
156156
await fileClient.upload(blob);
157-
const downloadedBlob = await (await fileClient.read()).contentAsBlob;
158-
assert.deepStrictEqual(downloadedBlob, blob);
157+
const downloadedBlob = await (await fileClient.read()).contentAsBlob!;
158+
assert.ok(arrayBufferEqual(await downloadedBlob.arrayBuffer(), await blob.arrayBuffer()));
159159

160160
await fileClient.upload(arrayBuf);
161-
const downloadedBlob1 = await (await fileClient.read()).contentAsBlob;
162-
assert.deepStrictEqual(downloadedBlob1, blob);
161+
const downloadedBlob1 = await (await fileClient.read()).contentAsBlob!;
162+
assert.ok(arrayBufferEqual(await downloadedBlob1.arrayBuffer(), await blob.arrayBuffer()));
163163

164164
const uint8ArrayPartial = new Uint8Array(arrayBuf, 1, 3);
165165
await fileClient.upload(uint8ArrayPartial);
166166
const downloadedBlob2 = await (await fileClient.read()).contentAsBlob!;
167-
assert.deepStrictEqual(
168-
downloadedBlob2,
169-
new Blob([uint8ArrayPartial], { type: "text/plain;charset=utf-8" })
170-
);
167+
assert.ok(arrayBufferEqual(await downloadedBlob2.arrayBuffer(), uint8ArrayPartial));
171168

172169
const uint16Array = new Uint16Array(arrayBuf, 4, 2);
173170
await fileClient.upload(uint16Array);
174171
const downloadedBlob3 = await (await fileClient.read()).contentAsBlob!;
175-
assert.deepStrictEqual(
176-
downloadedBlob3,
177-
new Blob([uint16Array], { type: "text/plain;charset=utf-8" })
172+
assert.ok(
173+
arrayBufferEqual(
174+
await downloadedBlob3.arrayBuffer(),
175+
new Uint8Array(uint16Array.buffer, uint16Array.byteOffset, uint16Array.byteLength)
176+
)
178177
);
179178
});
180179
});

sdk/storage/storage-file-datalake/test/filesystemclient.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ describe("DataLakeFileSystemClient", () => {
3737
serviceClient = getDataLakeServiceClient();
3838
fileSystemName = recorder.getUniqueName("filesystem");
3939
fileSystemClient = serviceClient.getFileSystemClient(fileSystemName);
40-
await fileSystemClient.create();
40+
await fileSystemClient.createIfNotExists();
4141
});
4242

4343
afterEach(async function() {
44-
await fileSystemClient.delete();
44+
await fileSystemClient.deleteIfExists();
4545
await recorder.stop();
4646
});
4747

@@ -146,7 +146,7 @@ describe("DataLakeFileSystemClient", () => {
146146
const createRes2 = await cClient.createIfNotExists({ metadata, access });
147147
assert.ok(!createRes2.succeeded);
148148

149-
await cClient.delete();
149+
await cClient.deleteIfExists();
150150
});
151151

152152
it("deleteIfExists", async () => {
@@ -463,12 +463,12 @@ describe("DataLakeFileSystemClient with soft delete", () => {
463463
}
464464

465465
fileSystemClient = serviceClient.getFileSystemClient(recorder.getUniqueName(`filesystem`));
466-
await fileSystemClient.create();
466+
await fileSystemClient.createIfNotExists();
467467
});
468468

469469
afterEach(async function() {
470470
if (fileSystemClient !== undefined) {
471-
await fileSystemClient.delete();
471+
await fileSystemClient.deleteIfExists();
472472
}
473473
await recorder.stop();
474474
});

sdk/storage/storage-file-datalake/test/leaseclient.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ describe("LeaseClient from FileSystem", () => {
2222
const serviceClient = getDataLakeServiceClient();
2323
fileSystemName = recorder.getUniqueName("filesystem");
2424
fileSystemClient = serviceClient.getFileSystemClient(fileSystemName);
25-
await fileSystemClient.create();
25+
await fileSystemClient.createIfNotExists();
2626
});
2727

2828
afterEach(async function() {
29-
await fileSystemClient.delete();
29+
await fileSystemClient.deleteIfExists();
3030
await recorder.stop();
3131
});
3232

@@ -154,14 +154,14 @@ describe("LeaseClient from File", () => {
154154
const serviceClient = getDataLakeServiceClient();
155155
fileSystemName = recorder.getUniqueName("filesystem");
156156
fileSystemClient = serviceClient.getFileSystemClient(fileSystemName);
157-
await fileSystemClient.create();
157+
await fileSystemClient.createIfNotExists();
158158
fileName = recorder.getUniqueName("file");
159159
fileClient = fileSystemClient.getFileClient(fileName);
160160
await fileClient.create();
161161
});
162162

163163
afterEach(async function() {
164-
await fileSystemClient.delete();
164+
await fileSystemClient.deleteIfExists();
165165
await recorder.stop();
166166
});
167167

@@ -277,14 +277,14 @@ describe("LeaseClient from Directory", () => {
277277
const serviceClient = getDataLakeServiceClient();
278278
fileSystemName = recorder.getUniqueName("filesystem");
279279
fileSystemClient = serviceClient.getFileSystemClient(fileSystemName);
280-
await fileSystemClient.create();
280+
await fileSystemClient.createIfNotExists();
281281
directoryName = recorder.getUniqueName("dir");
282282
directoryClient = fileSystemClient.getDirectoryClient(directoryName);
283283
await directoryClient.create();
284284
});
285285

286286
afterEach(async function() {
287-
await fileSystemClient.delete();
287+
await fileSystemClient.deleteIfExists();
288288
await recorder.stop();
289289
});
290290

sdk/storage/storage-file-datalake/test/node/filesystemclient.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ describe("DataLakeFileSystemClient Node.js only", () => {
2626
const serviceClient = getDataLakeServiceClient();
2727
fileSystemName = recorder.getUniqueName("filesystem");
2828
fileSystemClient = serviceClient.getFileSystemClient(fileSystemName);
29-
await fileSystemClient.create();
29+
await fileSystemClient.createIfNotExists();
3030
});
3131

3232
afterEach(async function() {
33-
await fileSystemClient.delete();
33+
await fileSystemClient.deleteIfExists();
3434
await recorder.stop();
3535
});
3636

sdk/storage/storage-file-datalake/test/node/highlevel.node.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,14 @@ describe("Highlevel Node.js only", () => {
5050
});
5151
fileSystemName = recorder.getUniqueName("filesystem");
5252
fileSystemClient = serviceClient.getFileSystemClient(fileSystemName);
53-
await fileSystemClient.create();
53+
await fileSystemClient.createIfNotExists();
5454
fileName = recorder.getUniqueName("file");
5555
fileClient = fileSystemClient.getFileClient(fileName);
5656
});
5757

5858
afterEach(async function(this: Context) {
5959
if (!this.currentTest?.isPending()) {
60-
await fileSystemClient.delete();
60+
await fileSystemClient.deleteIfExists();
6161
await recorder.stop();
6262
}
6363
});
@@ -250,7 +250,7 @@ describe("Highlevel Node.js only", () => {
250250
it("upload to a leased file should succeed when LeaseAccessConditions is specified", async () => {
251251
await fileClient.upload(Buffer.from("aaa"));
252252

253-
const duration = 30;
253+
const duration = 60;
254254
const leaseClient = fileClient.getDataLakeLeaseClient();
255255
await leaseClient.acquireLease(duration);
256256

sdk/storage/storage-file-datalake/test/node/pathclient.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ describe("DataLakePathClient Node.js only", () => {
4343
serviceClient = getDataLakeServiceClient();
4444
fileSystemName = recorder.getUniqueName("filesystem");
4545
fileSystemClient = serviceClient.getFileSystemClient(fileSystemName);
46-
await fileSystemClient.create();
46+
await fileSystemClient.createIfNotExists();
4747
fileName = recorder.getUniqueName("file");
4848
fileClient = fileSystemClient.getFileClient(fileName);
4949
await fileClient.create();
@@ -52,7 +52,7 @@ describe("DataLakePathClient Node.js only", () => {
5252
});
5353

5454
afterEach(async function() {
55-
await fileSystemClient.delete();
55+
await fileSystemClient.deleteIfExists();
5656
await recorder.stop();
5757
});
5858

@@ -342,7 +342,7 @@ describe("DataLakePathClient Node.js only", () => {
342342
await fileClient.move(destFileSystemName, destFileName);
343343

344344
await destFileClient.getProperties();
345-
await destFileSystemClient.delete();
345+
await destFileSystemClient.deleteIfExists();
346346
});
347347

348348
it("move should not encode / in the source", async () => {
@@ -463,7 +463,7 @@ describe("DataLakePathClient setAccessControlRecursive Node.js only", () => {
463463
serviceClient = getDataLakeServiceClient();
464464
fileSystemName = recorder.getUniqueName("filesystem");
465465
fileSystemClient = serviceClient.getFileSystemClient(fileSystemName);
466-
await fileSystemClient.create();
466+
await fileSystemClient.createIfNotExists();
467467
fileName = recorder.getUniqueName("file");
468468
fileClient = fileSystemClient.getFileClient(fileName);
469469
await fileClient.create();
@@ -472,7 +472,7 @@ describe("DataLakePathClient setAccessControlRecursive Node.js only", () => {
472472
});
473473

474474
afterEach(async function() {
475-
await fileSystemClient.delete();
475+
await fileSystemClient.deleteIfExists();
476476
await recorder.stop();
477477
});
478478

sdk/storage/storage-file-datalake/test/node/sas.spec.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ describe("Shared Access Signature (SAS) generation Node.js only", () => {
224224
.next()
225225
).value;
226226
assert.deepStrictEqual(result.pathItems.length, 0);
227-
await fileSystemClient.delete();
227+
await fileSystemClient.deleteIfExists();
228228
});
229229

230230
it("generateDataLakeSASQueryParameters should work for file with previous API version", async () => {
@@ -281,7 +281,7 @@ describe("Shared Access Signature (SAS) generation Node.js only", () => {
281281
assert.equal(properties.contentLanguage, "content-language-override");
282282
assert.equal(properties.contentType, "content-type-override");
283283

284-
await fileSystemClient.delete();
284+
await fileSystemClient.deleteIfExists();
285285
});
286286

287287
it("generateDataLakeSASQueryParameters should work for file", async () => {
@@ -338,7 +338,7 @@ describe("Shared Access Signature (SAS) generation Node.js only", () => {
338338
assert.equal(properties.contentLanguage, "content-language-override");
339339
assert.equal(properties.contentType, "content-type-override");
340340

341-
await fileSystemClient.delete();
341+
await fileSystemClient.deleteIfExists();
342342
});
343343

344344
it("generateDataLakeSASQueryParameters should work for file with special namings", async () => {
@@ -398,7 +398,7 @@ describe("Shared Access Signature (SAS) generation Node.js only", () => {
398398
assert.equal(properties.contentLanguage, "content-language-override");
399399
assert.equal(properties.contentType, "content-type-override");
400400

401-
await fileSystemClient.delete();
401+
await fileSystemClient.deleteIfExists();
402402
});
403403

404404
it("generateDataLakeSASQueryParameters should work for fileSystem with access policy", async () => {
@@ -456,7 +456,7 @@ describe("Shared Access Signature (SAS) generation Node.js only", () => {
456456
);
457457

458458
await fileClientWithSAS.getProperties();
459-
await fileSystemClient.delete();
459+
await fileSystemClient.deleteIfExists();
460460
});
461461

462462
it("generateDataLakeSASQueryParameters should work for file with access policy", async () => {
@@ -515,7 +515,7 @@ describe("Shared Access Signature (SAS) generation Node.js only", () => {
515515
);
516516

517517
await fileClientWithSAS.getProperties();
518-
await fileSystemClient.delete();
518+
await fileSystemClient.deleteIfExists();
519519
});
520520

521521
it("GenerateUserDelegationSAS should work for filesystem with all configurations", async function(this: Context) {
@@ -576,7 +576,7 @@ describe("Shared Access Signature (SAS) generation Node.js only", () => {
576576
.next()
577577
).value;
578578
assert.deepStrictEqual(result.pathItems.length, 0);
579-
await fileSystemClient.delete();
579+
await fileSystemClient.deleteIfExists();
580580
});
581581

582582
it("GenerateUserDelegationSAS should work for filesystem with minimum parameters", async function(this: Context) {
@@ -633,7 +633,7 @@ describe("Shared Access Signature (SAS) generation Node.js only", () => {
633633
.next()
634634
).value;
635635
assert.deepStrictEqual(result.pathItems.length, 0);
636-
await fileSystemClient.delete();
636+
await fileSystemClient.deleteIfExists();
637637
});
638638

639639
it("GenerateUserDelegationSAS should work for file", async function(this: Context) {
@@ -707,7 +707,7 @@ describe("Shared Access Signature (SAS) generation Node.js only", () => {
707707
assert.equal(properties.contentLanguage, "content-language-override");
708708
assert.equal(properties.contentType, "content-type-override");
709709

710-
await fileSystemClient.delete();
710+
await fileSystemClient.deleteIfExists();
711711
});
712712

713713
it("GenerateUserDelegationSAS should work for file for 2019-12-12", async function(this: Context) {
@@ -877,7 +877,7 @@ describe("Shared Access Signature (SAS) generation Node.js only", () => {
877877
it("DataLakeFileSystemClient.generateSasUrl() should work", async () => {
878878
const fileSystemName = recorder.getUniqueName("filesystem");
879879
const fileSystemClient = serviceClient.getFileSystemClient(fileSystemName);
880-
await fileSystemClient.create();
880+
await fileSystemClient.createIfNotExists();
881881

882882
const now = recorder.newDate("now");
883883
now.setMinutes(now.getMinutes() - 10); // Skip clock skew with server
@@ -912,7 +912,7 @@ describe("Shared Access Signature (SAS) generation Node.js only", () => {
912912
}
913913
assert.ok(exceptionCaught);
914914

915-
await fileSystemClient.delete();
915+
await fileSystemClient.deleteIfExists();
916916
});
917917
});
918918

@@ -952,7 +952,7 @@ describe("SAS generation Node.js only for directory SAS", () => {
952952

953953
const fileSystemName = recorder.getUniqueName("filesystem");
954954
fileSystemClient = serviceClient.getFileSystemClient(fileSystemName);
955-
await fileSystemClient.create();
955+
await fileSystemClient.createIfNotExists();
956956

957957
const directoryName = recorder.getUniqueName("directory");
958958
directoryClient = fileSystemClient.getDirectoryClient(directoryName);
@@ -971,7 +971,7 @@ describe("SAS generation Node.js only for directory SAS", () => {
971971
});
972972

973973
afterEach(async function() {
974-
await fileSystemClient.delete();
974+
await fileSystemClient.deleteIfExists();
975975
await recorder.stop();
976976
});
977977

@@ -1278,7 +1278,7 @@ describe("SAS generation Node.js only for delegation SAS", () => {
12781278

12791279
fileSystemName = recorder.getUniqueName("filesystem");
12801280
fileSystemClient = oauthServiceClient.getFileSystemClient(fileSystemName);
1281-
await fileSystemClient.create();
1281+
await fileSystemClient.createIfNotExists();
12821282

12831283
const directoryName = recorder.getUniqueName("directory");
12841284
directoryClient = fileSystemClient.getDirectoryClient(directoryName);
@@ -1291,7 +1291,7 @@ describe("SAS generation Node.js only for delegation SAS", () => {
12911291

12921292
afterEach(async function() {
12931293
if (fileSystemClient) {
1294-
await fileSystemClient.delete();
1294+
await fileSystemClient.deleteIfExists();
12951295
}
12961296
await recorder.stop();
12971297
});

sdk/storage/storage-file-datalake/test/pathclient.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ describe("DataLakePathClient", () => {
3030
const serviceClient = getDataLakeServiceClient();
3131
fileSystemName = recorder.getUniqueName("filesystem");
3232
fileSystemClient = serviceClient.getFileSystemClient(fileSystemName);
33-
await fileSystemClient.create();
33+
await fileSystemClient.createIfNotExists();
3434
fileName = recorder.getUniqueName("file");
3535
fileClient = fileSystemClient.getFileClient(fileName);
3636
await fileClient.create();
@@ -39,7 +39,7 @@ describe("DataLakePathClient", () => {
3939
});
4040

4141
afterEach(async function() {
42-
await fileSystemClient.delete();
42+
await fileSystemClient.deleteIfExists();
4343
await recorder.stop();
4444
});
4545

sdk/storage/storage-file-datalake/test/retrypolicy.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ describe("RetryPolicy", () => {
2626
serviceClient = getDataLakeServiceClient();
2727
fileSystemName = recorder.getUniqueName("container");
2828
dataLakeFileSystemClient = serviceClient.getFileSystemClient(fileSystemName);
29-
await dataLakeFileSystemClient.create();
29+
await dataLakeFileSystemClient.createIfNotExists();
3030
});
3131

3232
afterEach(async function() {
33-
await dataLakeFileSystemClient.delete();
33+
await dataLakeFileSystemClient.deleteIfExists();
3434
await recorder.stop();
3535
});
3636

0 commit comments

Comments
 (0)