-
Notifications
You must be signed in to change notification settings - Fork 0
/
parser_test.go
55 lines (53 loc) · 870 Bytes
/
parser_test.go
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
51
52
53
54
55
package wgapi
import (
"github.com/stretchr/testify/require"
"io"
"testing"
)
func TestIPCGet_Value(t *testing.T) {
for _, tt := range []struct {
name string
input string
}{
{
name: "invalid key",
input: "foo=bar\n",
},
{
name: "invalid line",
input: "foo\n",
},
{
name: "invalid value",
input: "fwmark=aa\n",
},
{
name: "invalid key",
input: "public_key=zz\n",
},
{
name: "invalid key length",
input: "public_key=ab\n",
},
{
name: "invalid true",
input: "remove=false\n",
},
{
name: "invalid ipnet",
input: "allowed_ip=..\n",
},
{
name: "invalid udp addr",
input: "endpoint=..\n",
},
} {
t.Run(tt.name, func(t *testing.T) {
var g IPCGet
_, err := io.WriteString(&g, tt.input)
require.NoError(t, err)
_, err = g.Value()
require.Error(t, err)
})
}
}