Skip to content

Commit

Permalink
Merge pull request #89 from cap-js/fix-attachments-test
Browse files Browse the repository at this point in the history
Fix attachments.test.js
  • Loading branch information
DanSchlachter authored Feb 28, 2025
2 parents d8ece8c + e87896f commit d1bd38a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions test/attachments.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,15 @@ describe('Test attachments service', () => {
id = `ID=${created.data.ID}` //> captures the newly created Attachments's ID for subsequent use...

// Upload the file
const filePath = path.join(cds.root, 'xmpls', 'SolarPanelReport.pdf');
const fileSize = require('fs').statSync(filePath).size;

const uploaded = await PUT (`${Incidents}_attachments(up__${ID},${id},${draft})/content`,
require('fs').createReadStream (cds.root+'/xmpls/SolarPanelReport.pdf'),
{ headers: { 'Content-Type': 'application/pdf' }}
require('fs').createReadStream (filePath),
{ headers: {
'Content-Type': 'application/pdf',
'Content-Length': fileSize
}}
)
expect(uploaded.status).to.equal(204)

Expand Down

0 comments on commit d1bd38a

Please sign in to comment.