-
Notifications
You must be signed in to change notification settings - Fork 150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add test for fs.appendFile to increase test coverage #629
Comments
I'm new to Open Source, but I would like to give this a try. |
@PriyankaCodes99 OK, it's all yours. Here's how I would recommend you approach this. First, you need a way to trigger this particular failure. Essentially, we want to have our test hit the code to deal with an invalid flag being passed. You can see the docs for appendFile, and they state that a flag is only valid if it's one of the strings in this list. So we should be able to cause it if we do something like this (NOTE: I did this in node.js): fs.appendFile('/file', 'data', { flag: 'invalid' }, function(err) { console.log(err); })
Error: Unknown file open flag: invalid
at stringToFlags (internal/fs.js:59:9)
at Object.fs.open (fs.js:637:16)
at Object.fs.writeFile (fs.js:1277:6)
at Object.fs.appendFile (fs.js:1332:6) Now we need to turn that snippet of code into a test case that we can run. The file where you want to do this is tests/spec/fs.appendFile.spec.js. So you want to add another Let me know if you have questions about this, and I can say more. |
@humphd Thanks! I'll keep you updated with my progress. |
We have a code path not being hit by our tests in
fs.appendFile
: https://codecov.io/gh/filerjs/filer/src/master/src/filesystem/implementation.js#L1895. To hit it, we need to:fs.appendFile
that pass invalid flags tooptions.flags
(i.e., doesn't includea
).The text was updated successfully, but these errors were encountered: