mardi 7 avril 2015

How to test io.writer in golang?

Recently I hope to write a unit test for golang. The function is as below.



func (s *containerStats) Display(w io.Writer) error {
fmt.Fprintf(w, "%s %s\n", "hello", "world")
return nil
}


So how can I test the result of "func Display" is "hello world"?


Aucun commentaire:

Enregistrer un commentaire