I have some code.  It uses ioutil.ReadDir which returns a possible error.

My testing is at 99% code coverage because I can't figure out a way to set up a situation in which os.Open succeeds on a directory, but ioutil.ReadDir fails.

I can get to 100% code coverage if I throw away the err rather than testing for it and reporting it but that seems a bit... well... disingenuous.  I've looked down the calls to the kernel call getdirentries but the only errno I can see being relevant to a go program is EIO and I can't think of a way to force that to happen on a real file system.

I can imagine a fake file system created specifically for this purpose, but that seems an awfully long way around the barn.

How can I get to 100% code coverage?  Or should I just give up on finding a way to cover that last, single line of error handling code?

--
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/19b6ffa0-301e-5b76-2bdf-4a4670f6d757%40juniper.net.

Reply via email to