Skip to content
Open
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ lib/**/*.js
*.auto.spec.js
integration-test/*.js
.vscode
.DS_Store
.DS_Store
test_file.bin
25 changes: 19 additions & 6 deletions lib/common/tests/node-request-generator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ describe("Test Request Generator ", () => {
? `${clientInfo} (${os.platform}/${os.release}; Node/${process.version}) ${appendUserAgent}`
: `${clientInfo} (${os.platform}/${os.release}; Node/${process.version})`;

const testFilePath = __dirname + "/resources/test_file.bin";
const largeString = "a".repeat(10485760);

before(() => {
fs.writeFileSync(testFilePath, largeString);
});

it("should compose request properly in Node environment", async function() {
const sdkRequest = await composeRequest({
baseEndpoint: "http://test-end-point/20191002",
Expand Down Expand Up @@ -61,9 +68,9 @@ describe("Test Request Generator ", () => {
"Content-Length": undefined,
"opc-retry-token": undefined
};
const fileLocation = __dirname + "/resources/large_file.bin";
const objectData = await fs.createReadStream(fileLocation);
const size = fs.statSync(fileLocation).size;

const objectData = await fs.createReadStream(testFilePath);
const size = fs.statSync(testFilePath).size;
const sdkRequest = await composeRequest({
baseEndpoint: "http://test-end-point/20191002",
defaultHeaders: {},
Expand Down Expand Up @@ -95,9 +102,9 @@ describe("Test Request Generator ", () => {
"Content-Length": undefined,
"opc-retry-token": undefined
};
const fileLocation = __dirname + "/resources/large_file.bin";
const size = fs.statSync(fileLocation).size;
const objectData = await fs.createReadStream(fileLocation);

const size = fs.statSync(testFilePath).size;
const objectData = await fs.createReadStream(testFilePath);
objectData.path = ""; // Force the path to be an empty string
const sdkRequest = await composeRequest({
baseEndpoint: "http://test-end-point/20191002",
Expand Down Expand Up @@ -193,4 +200,10 @@ describe("Test Request Generator ", () => {
"http://test-end-point/20191002/testUrl/Test-Id/actions?imageId=test&definedTagEquals=namespace1.key.val&definedTagEquals=namespace1.key.val2&definedTagEquals=namespace2.key.val&freeformTagEquals=ff1key.val&freeformTagEquals=ff2key.val"
);
});

after(() => {
if (fs.existsSync(testFilePath)) {
fs.rmSync(testFilePath);
}
});
});
1 change: 0 additions & 1 deletion lib/common/tests/resources/large_file.bin

This file was deleted.

Loading