(t *testing.T)
| 90 | } |
| 91 | |
| 92 | func 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 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…