|
1 | 1 | package e2e_test |
2 | 2 |
|
3 | 3 | import ( |
| 4 | + "bytes" |
4 | 5 | "fmt" |
5 | 6 | "net" |
6 | 7 | "net/url" |
@@ -135,22 +136,28 @@ var _ = Describe("podman machine start", func() { |
135 | 136 | }) |
136 | 137 |
|
137 | 138 | It("start only starts specified machine", func() { |
138 | | - i := initMachine{} |
139 | | - startme := randomString() |
140 | | - session, err := mb.setName(startme).setCmd(i.withImage(mb.imagePath)).run() |
141 | | - Expect(err).ToNot(HaveOccurred()) |
142 | | - Expect(session).To(Exit(0)) |
143 | | - |
144 | 139 | j := initMachine{} |
145 | 140 | dontstartme := randomString() |
146 | 141 | session2, err := mb.setName(dontstartme).setCmd(j.withFakeImage(mb)).run() |
147 | 142 | Expect(err).ToNot(HaveOccurred()) |
148 | 143 | Expect(session2).To(Exit(0)) |
149 | 144 |
|
| 145 | + i := initMachine{} |
| 146 | + startme := randomString() |
| 147 | + session, err := mb.setName(startme).setCmd(i.withImage(mb.imagePath)).run() |
| 148 | + Expect(err).ToNot(HaveOccurred()) |
| 149 | + Expect(session).To(Exit(0)) |
| 150 | + |
150 | 151 | s := &startMachine{} |
151 | | - session3, err := mb.setName(startme).setCmd(s).setTimeout(time.Minute * 10).run() |
| 152 | + // Provide a buffer as stdin to simulate non-tty input (e.g., piped or redirected stdin) |
| 153 | + // When stdin is not a tty, the command should not prompt for connection updates |
| 154 | + stdinBuf := bytes.NewBufferString("n\n") |
| 155 | + session3, err := mb.setName(startme).setCmd(s).setTimeout(time.Minute * 10).setStdin(stdinBuf).run() |
152 | 156 | Expect(err).ToNot(HaveOccurred()) |
153 | 157 | Expect(session3).Should(Exit(0)) |
| 158 | + // Verify that the prompt message did not appear (no prompting when stdin is not a tty) |
| 159 | + combinedOutput := session3.outputToString() + session3.errorToString() |
| 160 | + Expect(combinedOutput).ToNot(ContainSubstring("Set the default Podman connection to this machine"), "should not prompt when stdin is not a tty") |
154 | 161 |
|
155 | 162 | inspect := new(inspectMachine) |
156 | 163 | inspect = inspect.withFormat("{{.State}}") |
|
0 commit comments