Skip to content

Commit 6af97a7

Browse files
authored
Move test file creation step from ci-requirements script to test script for form data testing (#173)
* Move dummy file creation from ci-requirements to test.sh for form data
1 parent 06dd1d1 commit 6af97a7

File tree

3 files changed

+23
-10
lines changed

3 files changed

+23
-10
lines changed

npm/addPathToFormdataFile.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ var path = require('path'),
33
let collectionPath = path.resolve(__dirname, '../test/codegen/newman/fixtures/formdataFileCollection.json'),
44
collection = require(collectionPath),
55
formdata = collection.item[0].request.body.formdata;
6-
formdata[0].src = path.resolve(__dirname, '../test1.txt');
7-
formdata[1].src[0] = path.resolve(__dirname, '../test2.txt');
8-
formdata[1].src[1] = path.resolve(__dirname, '../test3.txt');
6+
formdata[0].src = path.resolve(__dirname, '../dummyFile1.txt');
7+
formdata[1].src[0] = path.resolve(__dirname, '../dummyFile2.txt');
8+
formdata[1].src[1] = path.resolve(__dirname, '../dummyFile3.txt');
99

1010
fs.writeFileSync(collectionPath, JSON.stringify(collection, null, 2), function (error) {
1111
if (error) {

npm/ci-requirements.sh

-7
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
#!/bin/bash
22
set -ev; # stop on error
3-
echo "Creating test files and adding paths to collection for testing form data file uploads"
4-
pushd /home/travis/build/postmanlabs/postman-code-generators/ &>/dev/null;
5-
echo "Sample file 1" >> test1.txt;
6-
echo "Sample file 2" >> test2.txt;
7-
echo "Sample file 3" >> test3.txt;
8-
node ./npm/addPathToFormdataFile.js
9-
popd &>/dev/null;
103

114
echo "Installing dependencies required for tests in codegens/java-okhttp"
125
pushd ./codegens/java-okhttp &>/dev/null;

npm/test.sh

+20
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,22 @@ else
1212
exit 1;
1313
fi
1414
popd &>/dev/null
15+
16+
echo "Creating test files and adding paths to collection for testing form data file uploads"
17+
if [ ! -e dummyFile1.txt ];
18+
then
19+
echo "Sample file 1" >> dummyFile1.txt;
20+
fi
21+
if [ ! -e dummyFile2.txt ];
22+
then
23+
echo "Sample file 2" >> dummyFile2.txt;
24+
fi
25+
if [ ! -e dummyFile3.txt ];
26+
then
27+
echo "Sample file 3" >> dummyFile3.txt;
28+
fi
29+
node ./npm/addPathToFormdataFile.js
30+
1531
echo "Running newman for common collection and storing results in newmanResponses.json"
1632
node ./test/codegen/newman/runNewman.js
1733

@@ -83,3 +99,7 @@ else
8399
done
84100

85101
fi
102+
103+
echo "Deleting test files used for testing form data file uploads"
104+
# Also handles the case when files does not exist
105+
rm -f -- dummyFile1.txt dummyFile2.txt dummyFile3.txt;

0 commit comments

Comments
 (0)