MCPcopy Create free account
hub / github.com/convox/rack / TestInstanceShell

Function TestInstanceShell

pkg/api/instance_test.go:66–94  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

64}
65
66func TestInstanceShell(t *testing.T) {
67 testServer(t, func(c *stdsdk.Client, p *structs.MockProvider) {
68 opts := structs.InstanceShellOptions{
69 Command: options.String("command"),
70 Height: options.Int(1),
71 Width: options.Int(2),
72 }
73 ro := stdsdk.RequestOptions{
74 Body: strings.NewReader("in"),
75 Headers: stdsdk.Headers{
76 "Command": "command",
77 "Height": "1",
78 "Width": "2",
79 },
80 }
81 p.On("InstanceShell", "instance1", mock.Anything, opts).Return(1, nil).Run(func(args mock.Arguments) {
82 rw := args.Get(1).(io.ReadWriter)
83 rw.Write([]byte("out"))
84 data, err := io.ReadAll(rw)
85 require.NoError(t, err)
86 require.Equal(t, "in", string(data))
87 })
88 r, err := c.Websocket("/instances/instance1/shell", ro)
89 require.NoError(t, err)
90 data, err := io.ReadAll(r)
91 require.NoError(t, err)
92 require.Equal(t, "outF1E49A85-0AD7-4AEF-A618-C249C6E6568D:1\n", string(data))
93 })
94}
95
96func TestInstanceShellError(t *testing.T) {
97 testServer(t, func(c *stdsdk.Client, p *structs.MockProvider) {

Callers

nothing calls this directly

Calls 7

StringFunction · 0.92
IntFunction · 0.92
WriteMethod · 0.80
WebsocketMethod · 0.80
testServerFunction · 0.70
RunMethod · 0.65
GetMethod · 0.65

Tested by

no test coverage detected