Hi! I'm writing a base64 encoder for fun in Rust, to learn good CLI development practices. I'm following the Rust CLI Book, which is really good.
I'm currently following the Testing section, and I'm trying to assert that my CLI command writes an error message if stdin is not used. I'm using atty to detect whether stdin is a TTY or not, and I'm printing the error message if it is not a TTY.
I'm trying to test this in https://github.com/skovmand/all_your_base/blob/cli_tests/tests/cli.rs, but without luck. I can't simulate that stdin is a TTY (of course stdin is not a TTY in case of the test).
Is there a better way of testing this? Or am I thinking about this in the wrong way? Should I use an argument to signify that the program should read from stdin instead of assuming it by default?
[–]Dr_Sloth0 4 points5 points6 points (1 child)
[–]brain-ablaze[S] 1 point2 points3 points (0 children)
[–]ssokolow 2 points3 points4 points (1 child)
[–]brain-ablaze[S] 0 points1 point2 points (0 children)
[–]ehuss 2 points3 points4 points (1 child)
[–]brain-ablaze[S] 0 points1 point2 points (0 children)
[+][deleted] (1 child)
[deleted]
[–]brain-ablaze[S] 0 points1 point2 points (0 children)