2
2
mirror of https://github.com/octoleo/restic.git synced 2024-11-30 00:33:57 +00:00
restic/internal/ui/termstatus/terminal_windows_test.go
2021-04-11 20:02:09 +02:00

31 lines
757 B
Go

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)
}
}