ui_writer_test.go 559 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package cli
  2. import (
  3. "io"
  4. "testing"
  5. )
  6. func TestUiWriter_impl(t *testing.T) {
  7. var _ io.Writer = new(UiWriter)
  8. }
  9. func TestUiWriter(t *testing.T) {
  10. ui := new(MockUi)
  11. w := &UiWriter{
  12. Ui: ui,
  13. }
  14. w.Write([]byte("foo\n"))
  15. w.Write([]byte("bar\n"))
  16. if ui.OutputWriter.String() != "foo\nbar\n" {
  17. t.Fatalf("bad: %s", ui.OutputWriter.String())
  18. }
  19. }
  20. func TestUiWriter_empty(t *testing.T) {
  21. ui := new(MockUi)
  22. w := &UiWriter{
  23. Ui: ui,
  24. }
  25. w.Write([]byte(""))
  26. if ui.OutputWriter.String() != "\n" {
  27. t.Fatalf("bad: %s", ui.OutputWriter.String())
  28. }
  29. }