github.com/hanks177/podman/v4@v4.1.3-0.20220613032544-16d90015bc83/pkg/machine/e2e/stop_test.go (about)

     1  package e2e
     2  
     3  import (
     4  	. "github.com/onsi/ginkgo"
     5  	. "github.com/onsi/gomega"
     6  	. "github.com/onsi/gomega/gexec"
     7  )
     8  
     9  var _ = Describe("podman machine stop", func() {
    10  	var (
    11  		mb      *machineTestBuilder
    12  		testDir string
    13  	)
    14  
    15  	BeforeEach(func() {
    16  		testDir, mb = setup()
    17  	})
    18  	AfterEach(func() {
    19  		teardown(originalHomeDir, testDir, mb)
    20  	})
    21  
    22  	It("stop bad name", func() {
    23  		i := stopMachine{}
    24  		reallyLongName := "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
    25  		session, err := mb.setName(reallyLongName).setCmd(&i).run()
    26  		Expect(err).To(BeNil())
    27  		Expect(session).To(Exit(125))
    28  	})
    29  
    30  	It("Stop running machine", func() {
    31  		i := new(initMachine)
    32  		session, err := mb.setCmd(i.withImagePath(mb.imagePath).withNow()).run()
    33  		Expect(err).To(BeNil())
    34  		Expect(session).To(Exit(0))
    35  
    36  		stop := new(stopMachine)
    37  		// Removing a running machine should fail
    38  		stopSession, err := mb.setCmd(stop).run()
    39  		Expect(err).To(BeNil())
    40  		Expect(stopSession).To(Exit(0))
    41  
    42  		// Stopping it again should not result in an error
    43  		stopAgain, err := mb.setCmd(stop).run()
    44  		Expect(err).To(BeNil())
    45  		Expect(stopAgain).To(Exit((0)))
    46  	})
    47  })