Skip to content

Commit

Permalink
merge and fix conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
ddelgrosso1 committed Sep 27, 2023
1 parent 1a0fe55 commit 7d74572
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 12 deletions.
12 changes: 8 additions & 4 deletions src/transfer-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ import AsyncRetry from 'async-retry';
import {ApiError} from './nodejs-common/index.js';
import {GaxiosResponse, Headers} from 'gaxios';
import {createHash} from 'crypto';
import {GCCL_GCS_CMD_KEY} from './nodejs-common/util';
import {getRuntimeTrackingString} from './util';
import {GCCL_GCS_CMD_KEY} from './nodejs-common/util.js';
import {getPackageJSON, getRuntimeTrackingString} from './util.js';

const packageJson = require('../../package.json');
const packageJson = getPackageJSON();

/**
* Default number of concurrently executing promises to use when calling uploadManyFiles.
Expand Down Expand Up @@ -248,7 +248,11 @@ class XMLMultiPartUploadHelper implements MultiPartUploadHelper {
if (res.data && res.data.error) {
throw res.data.error;
}
const parsedXML = this.xmlParser.parse(res.data);
const parsedXML = this.xmlParser.parse<{
InitiateMultipartUploadResult: {
UploadId: string;
};
}>(res.data);
this.uploadId = parsedXML.InitiateMultipartUploadResult.UploadId;
} catch (e) {
this.#handleErrorResponse(e as Error, bail);
Expand Down
7 changes: 3 additions & 4 deletions system-test/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,7 @@ describe('storage', () => {
beforeEach(() => {
delete process.env.GOOGLE_APPLICATION_CREDENTIALS;
delete process.env.GOOGLE_CLOUD_PROJECT;
delete require.cache[require.resolve('../src')];

// eslint-disable-next-line @typescript-eslint/no-var-requires
const {Storage} = require('../src');
storageWithoutAuth = new Storage({
retryOptions: {
idempotencyStrategy: IdempotencyStrategy.RetryAlways,
Expand Down Expand Up @@ -1701,7 +1698,9 @@ describe('storage', () => {

// Get the service account for the "second" account (the
// one that will read the requester pays file).
const clientEmail = require(key2!).client_email;
const clientEmail = JSON.parse(
fs.readFileSync(key2!, 'utf-8')
).client_email;

policy.bindings.push({
role: 'roles/storage.admin',
Expand Down
4 changes: 3 additions & 1 deletion test/nodejs-common/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,9 @@ describe('Service', () => {
service.makeAuthenticatedRequest = (reqOpts: DecorateRequestOptions) => {
const pkg = service.packageJson;
const r = new RegExp(
`^gl-node/${process.versions.node} gccl/${pkg.version} gccl-invocation-id/(?<gcclInvocationId>[^W]+) gccl-gcs-cmd/${expected}$`
`^gl-node/${process.versions.node} gccl/${
pkg.version
}-${getModuleFormat()} gccl-invocation-id/(?<gcclInvocationId>[^W]+) gccl-gcs-cmd/${expected}$`
);
assert.ok(r.test(reqOpts.headers!['x-goog-api-client']));
done();
Expand Down
1 change: 1 addition & 0 deletions test/nodejs-common/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import {
Abortable,
ApiError,
DecorateRequestOptions,
Duplexify,
GCCL_GCS_CMD_KEY,
GoogleErrorBody,
GoogleInnerError,
Expand Down
6 changes: 3 additions & 3 deletions test/transfer-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,13 +299,13 @@ describe('Transfer Manager', () => {
}

before(async () => {
directory = await fsp.mkdtemp(
directory = await promises.mkdtemp(
path.join(tmpdir(), 'tm-uploadFileInChunks-')
);

filePath = path.join(directory, 't.txt');

await fsp.writeFile(filePath, 'hello');
await promises.writeFile(filePath, 'hello');
});

beforeEach(async () => {
Expand All @@ -323,7 +323,7 @@ describe('Transfer Manager', () => {
});

after(async () => {
await fsp.rm(directory, {force: true, recursive: true});
await promises.rm(directory, {force: true, recursive: true});
});

it('should call initiateUpload, uploadPart, and completeUpload', async () => {
Expand Down

0 comments on commit 7d74572

Please sign in to comment.