notify/internal/transport/stream_test.go

45 lines
1.2 KiB
Go
Raw Normal View History

package transport
import "testing"
func TestNamedPipeNetworkAliases(t *testing.T) {
tests := []struct {
network string
want bool
}{
{network: "npipe", want: true},
{network: "pipe", want: true},
{network: "namedpipe", want: true},
{network: "named-pipe", want: true},
{network: "tcp", want: false},
{network: "unix", want: false},
}
for _, tt := range tests {
if got := IsNamedPipeNetwork(tt.network); got != tt.want {
t.Fatalf("IsNamedPipeNetwork(%q) = %v, want %v", tt.network, got, tt.want)
}
}
}
func TestNormalizeNamedPipeAddr(t *testing.T) {
tests := []struct {
name string
addr string
want string
}{
{name: "short-name", addr: "notify-demo", want: `\\.\pipe\notify-demo`},
{name: "pipe-prefix", addr: `pipe\notify-demo`, want: `\\.\pipe\notify-demo`},
{name: "slash-prefix", addr: "//./pipe/notify-demo", want: `\\.\pipe\notify-demo`},
{name: "normalized", addr: `\\.\pipe\notify-demo`, want: `\\.\pipe\notify-demo`},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := NormalizeNamedPipeAddr(tt.addr); got != tt.want {
t.Fatalf("NormalizeNamedPipeAddr(%q) = %q, want %q", tt.addr, got, tt.want)
}
})
}
}