Add tests for status output

Test: status_test.go
Change-Id: If3febd8fdacb0e70716d0520a41c982bd6474720
This commit is contained in:
Colin Cross
2019-06-08 21:59:42 -07:00
parent e51e2feafd
commit dde49cb687
3 changed files with 307 additions and 0 deletions

View File

@@ -29,6 +29,8 @@ func isTerminal(w io.Writer) bool {
ioctlGetTermios, uintptr(unsafe.Pointer(&termios)),
0, 0, 0)
return err == 0
} else if _, ok := w.(*fakeSmartTerminal); ok {
return true
}
return false
}
@@ -43,6 +45,8 @@ func termWidth(w io.Writer) (int, bool) {
syscall.TIOCGWINSZ, uintptr(unsafe.Pointer(&winsize)),
0, 0, 0)
return int(winsize.ws_column), err == 0
} else if f, ok := w.(*fakeSmartTerminal); ok {
return f.termWidth, true
}
return 0, false
}
@@ -99,3 +103,8 @@ func stripAnsiEscapes(input []byte) []byte {
return input
}
type fakeSmartTerminal struct {
bytes.Buffer
termWidth int
}