MCPcopy Create free account
hub / github.com/containerd/nerdctl / TestExecTTY

Function TestExecTTY

cmd/nerdctl/container/container_exec_linux_test.go:92–149  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

90}
91
92func TestExecTTY(t *testing.T) {
93 const sttyPartialOutput = "speed 38400 baud"
94
95 testCase := nerdtest.Setup()
96
97 testCase.Cleanup = func(data test.Data, helpers test.Helpers) {
98 helpers.Ensure("rm", "-f", data.Identifier())
99 }
100
101 testCase.Setup = func(data test.Data, helpers test.Helpers) {
102 helpers.Ensure("run", "-d", "--name", data.Identifier(), testutil.CommonImage, "sleep", nerdtest.Infinity)
103
104 nerdtest.EnsureContainerStarted(helpers, data.Identifier())
105
106 data.Labels().Set("container_name", data.Identifier())
107 }
108
109 testCase.SubTests = []*test.Case{
110 {
111 Description: "stty with -it",
112 Command: func(data test.Data, helpers test.Helpers) test.TestableCommand {
113 cmd := helpers.Command("exec", "-it", data.Labels().Get("container_name"), "stty")
114 cmd.WithPseudoTTY()
115 return cmd
116 },
117 Expected: test.Expects(0, nil, expect.Contains(sttyPartialOutput)),
118 },
119 {
120 Description: "stty with -t",
121 Command: func(data test.Data, helpers test.Helpers) test.TestableCommand {
122 cmd := helpers.Command("exec", "-t", data.Labels().Get("container_name"), "stty")
123 cmd.WithPseudoTTY()
124 return cmd
125 },
126 Expected: test.Expects(0, nil, expect.Contains(sttyPartialOutput)),
127 },
128 {
129 Description: "stty with -i",
130 Command: func(data test.Data, helpers test.Helpers) test.TestableCommand {
131 cmd := helpers.Command("exec", "-i", data.Labels().Get("container_name"), "stty")
132 cmd.WithPseudoTTY()
133 return cmd
134 },
135 Expected: test.Expects(expect.ExitCodeGenericFail, nil, nil),
136 },
137 {
138 Description: "stty without params",
139 Command: func(data test.Data, helpers test.Helpers) test.TestableCommand {
140 cmd := helpers.Command("exec", data.Labels().Get("container_name"), "stty")
141 cmd.WithPseudoTTY()
142 return cmd
143 },
144 Expected: test.Expects(expect.ExitCodeGenericFail, nil, nil),
145 },
146 }
147
148 testCase.Run(t)
149}

Callers

nothing calls this directly

Calls 10

SetupFunction · 0.92
EnsureContainerStartedFunction · 0.92
EnsureMethod · 0.65
IdentifierMethod · 0.65
SetMethod · 0.65
LabelsMethod · 0.65
CommandMethod · 0.65
GetMethod · 0.65
WithPseudoTTYMethod · 0.65
RunMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…