Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 15 additions & 18 deletions system-test/kitchen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// limitations under the License.

import * as assert from 'assert';
import {describe, it, beforeEach} from 'mocha';
import {describe, it} from 'mocha';
import * as fs from 'fs';
import * as path from 'path';
import * as tmp from 'tmp';
Expand Down Expand Up @@ -60,21 +60,15 @@ describe('resumable-upload', () => {

before(async () => {
tmp.setGracefulCleanup();
filePath = path.join(os.tmpdir(), '20MB.zip');
const fileName = 'test-20MB.zip';
filePath = path.join(os.tmpdir(), fileName);

await fs.promises.writeFile(filePath, crypto.randomBytes(FILE_SIZE));
});

beforeEach(() => {
upload({
bucket: bucketName,
file: filePath,
retryOptions: retryOptions,
});
});

afterEach(async () => {
await bucket.file(filePath).delete({ignoreNotFound: true});
const remoteFileName = path.basename(filePath);
await bucket.file(remoteFileName).delete({ignoreNotFound: true});
});

after(async () => {
Expand Down Expand Up @@ -107,14 +101,14 @@ describe('resumable-upload', () => {
.pipe(
upload({
bucket: bucketName,
file: filePath,
file: path.basename(filePath),
retryOptions: retryOptions,
metadata: {contentType: 'image/jpg'},
})
)
.on('error', done)
.on('response', resp => {
uploadSucceeded = resp.status === 200;
uploadSucceeded = resp.status >= 200 && resp.status < 300;
})
.on('finish', () => {
assert.strictEqual(uploadSucceeded, true);
Expand Down Expand Up @@ -322,26 +316,29 @@ describe('resumable-upload', () => {
.pipe(
upload({
bucket: bucketName,
file: filePath,
file: path.basename(filePath),
crc32c: true,
clientCrc32c: crc32c,
retryOptions: retryOptions,
})
)
.on('error', err => {
console.log(err);
done(
new Error(
`Upload failed unexpectedly on success path: ${err.message}`
)
);
})
.on('response', resp => {
uploadSucceeded = resp.status === 200;
uploadSucceeded = resp.status >= 200 && resp.status < 300;
})
.on('finish', () => {
assert.strictEqual(uploadSucceeded, true);
done();
try {
assert.strictEqual(uploadSucceeded, true);
done();
} catch (error) {
done(error);
}
});
});

Expand Down
Loading