test: add test coverage for fs.truncate#23620
Conversation
|
Hello @christian-bromann and thank you for the contribution 🥇 |
|
the following: Lines 617 to 622 in bcbb937 Is a sort of JS idiom to handle optional function arguments. IMHO it could stay as as. |
test/parallel/test-fs-truncate.js
Outdated
There was a problem hiding this comment.
If we are expecting an error, its bettor to explicitly assert the error. But, I think you meant to write assert.ifError here.
There was a problem hiding this comment.
Since this passes CI, I'm assuming it fails with code ENOENT.
Assertion should have been near
node/test/parallel/test-fs-error-messages.js
Lines 521 to 545 in 9f7e3a4
But since it's not, I agree it should be here.
13a578a to
7299332
Compare
|
@thefourtheye added explicit check for error |
test/parallel/test-fs-truncate.js
Outdated
There was a problem hiding this comment.
Nit: maybe use some more descriptive filename that will indicate that this file is indeed non-existent and make sure that nobody creates it accidentally (via other test), perhaps: 'non-existent-truncate-file.txt'?
test/parallel/test-fs-truncate.js
Outdated
There was a problem hiding this comment.
Nit: this line should be aligned to the '
7299332 to
2a1b66d
Compare
|
It says |
|
/cc @Trott @christian-bromann It’s not the first time that that happened, but I think we thought we had fixed it. I don’t think you need to do anything here, though. |
|
Maybe to add context to this situation: I used |
2a1b66d to
106a6ed
Compare
Add test to check: - for `null` as len parameter - if error is propagated into callback if file doesn't exist - if an error is actually thrown if len is not a number PR-URL: nodejs#23620 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Denys Otrishko <shishugi@gmail.com>
106a6ed to
74f854e
Compare
|
Landed in 74f854e 🎉 |
Will try my best. Thanks for the support. I really enjoyed the code and learn session at Node+JS Interactive. |
Add test to check: - for `null` as len parameter - if error is propagated into callback if file doesn't exist - if an error is actually thrown if len is not a number PR-URL: #23620 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Denys Otrishko <shishugi@gmail.com>
Add test to check: - for `null` as len parameter - if error is propagated into callback if file doesn't exist - if an error is actually thrown if len is not a number PR-URL: #23620 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Denys Otrishko <shishugi@gmail.com>
Add test to check: - for `null` as len parameter - if error is propagated into callback if file doesn't exist - if an error is actually thrown if len is not a number PR-URL: #23620 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Denys Otrishko <shishugi@gmail.com>
Add test to check: - for `null` as len parameter - if error is propagated into callback if file doesn't exist - if an error is actually thrown if len is not a number PR-URL: #23620 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Denys Otrishko <shishugi@gmail.com>
Add test to check: - for `null` as len parameter - if error is propagated into callback if file doesn't exist - if an error is actually thrown if len is not a number PR-URL: #23620 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Denys Otrishko <shishugi@gmail.com>


Add test to check:
nullas len parameterI think it is safe to say that we could remove:
because there is an
validateInteger(len, 'len');right after. Another option would be to just setlento0for all cases it is not aNumber. What do you think?Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes