guptarohit/asciigraph

Add tests for CLI

Opened this issue · 2 comments

We should have tests for CLI as well

Do you have any idea on how to make the tests for CLI? I am quite new to go, I've done some testing on Rust, and I took a look at asciigraph_test.go file and understand how it works. But how can I test the for s.Scan() { ... } block on line 104? Do you have any resource or example I can take as source of inspiration? Would you like to test the flags passed to CLI are doing the right thing?

This would be tricky, possibly we have to redirect stdin & stdout. Redirect os.stdout to some in-memory buffer or temp file maybe? And similarly, pass out input test data to os.stdin.
Unfortunately atm I don't have any related resource for it, but if I find anything related to it I'll share here.
Yes, testing flags as well would be good idea.