2
2
mirror of https://github.com/octoleo/restic.git synced 2024-11-11 07:41:03 +00:00
restic/internal/ui/termstatus/terminal_windows_test.go

31 lines
757 B
Go
Raw Normal View History

2021-03-10 22:02:32 +00:00
package termstatus
import (
"syscall"
"testing"
"golang.org/x/sys/windows"
rtest "github.com/restic/restic/internal/test"
)
func TestIsMinTTY(t *testing.T) {
for _, test := range []struct {
path string
result bool
}{
{`\\.\pipe\msys-dd50a72ab4668b33-pty0-to-master`, true},
{`\\.\pipe\msys-dd50a72ab4668b33-13244-pipe-0x16`, false},
} {
filename, err := syscall.UTF16FromString(test.path)
rtest.OK(t, err)
handle, err := windows.CreateNamedPipe(&filename[0], windows.PIPE_ACCESS_DUPLEX,
windows.PIPE_TYPE_BYTE, 1, 1024, 1024, 0, nil)
rtest.OK(t, err)
defer windows.CloseHandle(handle)
rtest.Assert(t, CanUpdateStatus(uintptr(handle)) == test.result,
"expected CanUpdateStatus(%v) == %v", test.path, test.result)
}
}