-
-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathtunnel_linux_test.go
More file actions
50 lines (44 loc) · 970 Bytes
/
tunnel_linux_test.go
File metadata and controls
50 lines (44 loc) · 970 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//go:build linux
package sshlib
import (
"errors"
"os"
"strings"
"testing"
)
func TestFormatLinuxTunnelOpenError(t *testing.T) {
t.Parallel()
tests := []struct {
name string
err error
contains []string
}{
{
name: "not exist",
err: os.ErrNotExist,
contains: []string{"/dev/net/tun", "unavailable", "tun module", "NET_ADMIN"},
},
{
name: "permission",
err: os.ErrPermission,
contains: []string{"/dev/net/tun", "permission denied", "CAP_NET_ADMIN"},
},
{
name: "other",
err: errors.New("boom"),
contains: []string{"/dev/net/tun", "boom"},
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
got := formatLinuxTunnelOpenError(tt.err).Error()
for _, want := range tt.contains {
if !strings.Contains(got, want) {
t.Fatalf("formatLinuxTunnelOpenError(%v) = %q, want substring %q", tt.err, got, want)
}
}
})
}
}