MCPcopy
hub / github.com/node-formidable/formidable / uploadFixture

Function uploadFixture

test/integration/fixtures.test.js:90–130  ·  view source on GitHub ↗
(fixtureName, cb)

Source from the content-addressed store, hash-verified

88 }
89
90 function uploadFixture(fixtureName, cb) {
91 server.once('request', (req, res) => {
92 const form = formidable({
93 uploadDir: UPLOAD_DIR,
94 hashAlgorithm: 'sha1',
95 });
96 form.parse(req);
97
98 function callback(...args) {
99 const realCallback = cb;
100 // eslint-disable-next-line no-param-reassign
101 cb = function callbackFn() {};
102
103 realCallback(...args);
104 }
105
106 const parts = [];
107 form
108 .on('error', callback)
109 .on('fileBegin', (name, value) => {
110 parts.push({ type: 'file', name, value });
111 })
112 .on('field', (name, value) => {
113 parts.push({ type: 'field', name, value });
114 })
115 .on('end', () => {
116 res.end();
117 callback(null, parts);
118 });
119 });
120
121 const socket = createConnection(PORT);
122 const fixturePath = join(FIXTURES_HTTP, fixtureName);
123 const file = createReadStream(fixturePath);
124
125 file.pipe(socket, { end: false });
126
127 socket.on('data', () => {
128 socket.end();
129 });
130 }
131});

Callers 1

testNextFunction · 0.85

Calls 4

formidableFunction · 0.85
callbackFunction · 0.85
parseMethod · 0.80
endMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…