mirror of
https://github.com/containers/podman.git
synced 2025-10-20 20:54:45 +08:00
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>
This commit is contained in:
committed by
Matthew Heon
parent
ce790e61b1
commit
69fcf04c69
@ -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)
|
||||
}
|
||||
|
||||
@ -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))
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user