aboutsummaryrefslogtreecommitdiff
path: root/pkg/machine/e2e/stop_test.go
blob: 5dee6a345ea0e727cf1f82bd990013a0c7d68585 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package e2e

import (
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("podman machine stop", func() {
	var (
		mb      *machineTestBuilder
		testDir string
	)

	BeforeEach(func() {
		testDir, mb = setup()
	})
	AfterEach(func() {
		teardown(originalHomeDir, testDir, mb)
	})

	It("stop bad name", func() {
		i := stopMachine{}
		reallyLongName := "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
		session, err := mb.setName(reallyLongName).setCmd(&i).run()
		Expect(err).To(BeNil())
		Expect(session.ExitCode()).To(Equal(125))
	})

	It("Stop running machine", func() {
		i := new(initMachine)
		session, err := mb.setCmd(i.withImagePath(mb.imagePath).withNow()).run()
		Expect(err).To(BeNil())
		Expect(session.ExitCode()).To(Equal(0))

		stop := new(stopMachine)
		// Removing a running machine should fail
		stopSession, err := mb.setCmd(stop).run()
		Expect(err).To(BeNil())
		Expect(stopSession.ExitCode()).To(Equal(0))

		// Stopping it again should not result in an error
		stopAgain, err := mb.setCmd(stop).run()
		Expect(err).To(BeNil())
		Expect(stopAgain.ExitCode()).To(BeZero())
	})
})