diff options
author | Paul Holzinger <pholzing@redhat.com> | 2022-07-21 11:41:13 +0200 |
---|---|---|
committer | Paul Holzinger <pholzing@redhat.com> | 2022-07-21 18:04:11 +0200 |
commit | 604920dd1101c030545f4ff547b86a507b5c3ff1 (patch) | |
tree | b17fbb83d379936ac14a387ca027452b41d819c4 | |
parent | ee35ce86d0766a52ce223f2ac765b5d787e4ab89 (diff) | |
download | podman-604920dd1101c030545f4ff547b86a507b5c3ff1.tar.gz podman-604920dd1101c030545f4ff547b86a507b5c3ff1.tar.bz2 podman-604920dd1101c030545f4ff547b86a507b5c3ff1.zip |
fix some pkg/machine/e2e test to read stderr
Also fix the machine ssh code order to provide a better error message.
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
-rw-r--r-- | cmd/podman/machine/ssh.go | 9 | ||||
-rw-r--r-- | pkg/machine/e2e/ssh_test.go | 6 |
2 files changed, 7 insertions, 8 deletions
diff --git a/cmd/podman/machine/ssh.go b/cmd/podman/machine/ssh.go index cb2f62f51..8534b8efa 100644 --- a/cmd/podman/machine/ssh.go +++ b/cmd/podman/machine/ssh.go @@ -80,6 +80,11 @@ func ssh(cmd *cobra.Command, args []string) error { } } + vm, err = provider.LoadVMByName(vmName) + if err != nil { + return fmt.Errorf("vm %s not found: %w", vmName, err) + } + if !validVM && sshOpts.Username == "" { sshOpts.Username, err = remoteConnectionUsername() if err != nil { @@ -87,10 +92,6 @@ func ssh(cmd *cobra.Command, args []string) error { } } - vm, err = provider.LoadVMByName(vmName) - if err != nil { - return fmt.Errorf("vm %s not found: %w", vmName, err) - } err = vm.SSH(vmName, sshOpts) return utils.HandleOSExecError(err) } diff --git a/pkg/machine/e2e/ssh_test.go b/pkg/machine/e2e/ssh_test.go index 6d23a024e..52d714c91 100644 --- a/pkg/machine/e2e/ssh_test.go +++ b/pkg/machine/e2e/ssh_test.go @@ -25,8 +25,7 @@ var _ = Describe("podman machine ssh", func() { session, err := mb.setName(name).setCmd(ssh).run() Expect(err).To(BeNil()) Expect(session).To(Exit(125)) - // TODO seems like stderr is not being returned; re-enabled when fixed - // Expect(session.outputToString()).To(ContainSubstring("not exist")) + Expect(session.errorToString()).To(ContainSubstring("not exist")) }) It("ssh to non-running machine", func() { @@ -39,8 +38,7 @@ var _ = Describe("podman machine ssh", func() { ssh := sshMachine{} sshSession, err := mb.setName(name).setCmd(ssh).run() Expect(err).To(BeNil()) - // TODO seems like stderr is not being returned; re-enabled when fixed - // Expect(sshSession.outputToString()).To(ContainSubstring("is not running")) + Expect(sshSession.errorToString()).To(ContainSubstring("is not running")) Expect(sshSession).To(Exit(125)) }) |