I get confused when trying to write a test for simple console app in Golang. the function I want to test is very simple.
func SimpleFunc() {
reader := bufio.NewReader(os.Stdin)
output, _ := reader.ReadString('\n')
fmt.Println(output)
}
Could you give an example how to write a test to mock stdin and stdout in Golang?
Thanks in advance
Aucun commentaire:
Enregistrer un commentaire