mirror of
https://github.com/podman-container-tools/podman.git
synced 2026-10-11 00:17:41 +00:00
pkg/machine/e2e: simplify runWslCommand
runWslCommand never returns err != nil because if there's an error, it calls Fail (which panics, so the code after it is unreachable).
Remove error returning and checking.
Inspired by the following linter warning:
> pkg/machine/e2e/config_windows_test.go:59:56: runWslCommand - result 1 (error) is always nil (unparam)
> func runWslCommand(cmdArgs []string) (*machineSession, error) {
> ^
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
(cherry picked from commit 94442ae44e)
Signed-off-by: Lokesh Mandvekar <lsm5@redhat.com>
This commit is contained in:
parent
53ed0d02e4
commit
e1e89017ca
2 changed files with 7 additions and 20 deletions
|
|
@ -38,16 +38,15 @@ func getOtherProvider() string {
|
|||
return ""
|
||||
}
|
||||
|
||||
func runWslCommand(cmdArgs []string) (*machineSession, error) {
|
||||
func runWslCommand(cmdArgs []string) *machineSession {
|
||||
binary := "wsl"
|
||||
GinkgoWriter.Println(binary + " " + strings.Join(cmdArgs, " "))
|
||||
c := exec.Command(binary, cmdArgs...)
|
||||
session, err := Start(c, GinkgoWriter, GinkgoWriter)
|
||||
if err != nil {
|
||||
Fail(fmt.Sprintf("Unable to start session: %q", err))
|
||||
return nil, err
|
||||
}
|
||||
ms := machineSession{session}
|
||||
ms.waitWithTimeout(defaultTimeout)
|
||||
return &ms, nil
|
||||
return &ms
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,15 +27,8 @@ var _ = Describe("podman machine init - windows only", func() {
|
|||
Expect(session).To(Exit(0))
|
||||
|
||||
defer func() {
|
||||
_, err := runWslCommand([]string{"--terminate", "podman-net-usermode"})
|
||||
if err != nil {
|
||||
fmt.Println("unable to terminate podman-net-usermode")
|
||||
}
|
||||
|
||||
_, err = runWslCommand([]string{"--unregister", "podman-net-usermode"})
|
||||
if err != nil {
|
||||
fmt.Println("unable to unregister podman-net-usermode")
|
||||
}
|
||||
runWslCommand([]string{"--terminate", "podman-net-usermode"})
|
||||
runWslCommand([]string{"--unregister", "podman-net-usermode"})
|
||||
}()
|
||||
|
||||
inspect := new(inspectMachine)
|
||||
|
|
@ -105,20 +98,15 @@ var _ = Describe("podman machine init - windows only", func() {
|
|||
// a vm outside the context of podman-machine and also
|
||||
// so we dont have to download a distribution from microsoft
|
||||
// servers
|
||||
exportSession, err := runWslCommand([]string{"--export", "podman-foobarexport", exportedPath})
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
exportSession := runWslCommand([]string{"--export", "podman-foobarexport", exportedPath})
|
||||
Expect(exportSession).To(Exit(0))
|
||||
|
||||
// importing the machine and creating a vm
|
||||
importSession, err := runWslCommand([]string{"--import", distName, distrDir, exportedPath})
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
importSession := runWslCommand([]string{"--import", distName, distrDir, exportedPath})
|
||||
Expect(importSession).To(Exit(0))
|
||||
|
||||
defer func() {
|
||||
_, err := runWslCommand([]string{"--unregister", distName})
|
||||
if err != nil {
|
||||
fmt.Println("unable to remove bogus wsl instance")
|
||||
}
|
||||
runWslCommand([]string{"--unregister", distName})
|
||||
}()
|
||||
|
||||
// Trying to make a vm with the same name as an existing name should result in a 125
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue