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

Function TestProcessExec

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

Source from the content-addressed store, hash-verified

32}
33
34func TestProcessExec(t *testing.T) {
35 testServer(t, func(c *stdsdk.Client, p *structs.MockProvider) {
36 a1 := fxApp
37 p.On("AppGet", "app1").Return(&a1, nil)
38 opts := structs.ProcessExecOptions{
39 Entrypoint: options.Bool(true),
40 Height: options.Int(1),
41 Tty: options.Bool(true),
42 Width: options.Int(2),
43 }
44 ro := stdsdk.RequestOptions{
45 Body: strings.NewReader("in"),
46 Headers: stdsdk.Headers{
47 "Command": "command",
48 "Entrypoint": "true",
49 "Height": "1",
50 "Width": "2",
51 },
52 }
53 p.On("ProcessExec", "app1", "pid1", "command", mock.Anything, opts).Return(1, nil).Run(func(args mock.Arguments) {
54 rw := args.Get(3).(io.ReadWriter)
55 rw.Write([]byte("out"))
56 data, err := io.ReadAll(rw)
57 require.NoError(t, err)
58 require.Equal(t, "in", string(data))
59 })
60 r, err := c.Websocket("/apps/app1/processes/pid1/exec", ro)
61 require.NoError(t, err)
62 data, err := io.ReadAll(r)
63 require.NoError(t, err)
64 require.Equal(t, "outF1E49A85-0AD7-4AEF-A618-C249C6E6568D:1\n", string(data))
65 })
66}
67
68func TestProcessLogs(t *testing.T) {
69 testServer(t, func(c *stdsdk.Client, p *structs.MockProvider) {

Callers

nothing calls this directly

Calls 7

BoolFunction · 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