MCPcopy Index your code
hub / github.com/coder/coder / TestVPNDaemonRun

Function TestVPNDaemonRun

cli/vpndaemon_windows_linux_shared_test.go:16–105  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

14)
15
16func TestVPNDaemonRun(t *testing.T) {
17 t.Parallel()
18
19 t.Run("InvalidFlags", func(t *testing.T) {
20 t.Parallel()
21
22 cases := []struct {
23 Name string
24 Args []string
25 ErrorContains string
26 }{
27 {
28 Name: "NoReadHandle",
29 Args: []string{"--rpc-write-handle", "10"},
30 ErrorContains: "rpc-read-handle",
31 },
32 {
33 Name: "NoWriteHandle",
34 Args: []string{"--rpc-read-handle", "10"},
35 ErrorContains: "rpc-write-handle",
36 },
37 {
38 Name: "NegativeReadHandle",
39 Args: []string{"--rpc-read-handle", "-1", "--rpc-write-handle", "10"},
40 ErrorContains: "rpc-read-handle",
41 },
42 {
43 Name: "NegativeWriteHandle",
44 Args: []string{"--rpc-read-handle", "10", "--rpc-write-handle", "-1"},
45 ErrorContains: "rpc-write-handle",
46 },
47 {
48 Name: "SameHandles",
49 Args: []string{"--rpc-read-handle", "10", "--rpc-write-handle", "10"},
50 ErrorContains: "rpc-read-handle",
51 },
52 }
53
54 for _, c := range cases {
55 t.Run(c.Name, func(t *testing.T) {
56 t.Parallel()
57 ctx := testutil.Context(t, testutil.WaitLong)
58 inv, _ := clitest.New(t, append([]string{"vpn-daemon", "run"}, c.Args...)...)
59 err := inv.WithContext(ctx).Run()
60 require.ErrorContains(t, err, c.ErrorContains)
61 })
62 }
63 })
64
65 t.Run("StartsTunnel", func(t *testing.T) {
66 t.Parallel()
67
68 r1, w1, err := os.Pipe()
69 require.NoError(t, err)
70 defer w1.Close()
71
72 r2, w2, err := os.Pipe()
73 require.NoError(t, err)

Callers

nothing calls this directly

Calls 9

ContextFunction · 0.92
NewFunction · 0.92
StartWithWaiterFunction · 0.92
WithContextMethod · 0.80
dupHandleFunction · 0.70
RunMethod · 0.65
CloseMethod · 0.65
WriteMethod · 0.65
WaitMethod · 0.65

Tested by

no test coverage detected