File: machine_test.go

package info (click to toggle)
golang-github-containers-common 0.50.1%2Bds1-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 4,440 kB
  • sloc: makefile: 118; sh: 46
file content (54 lines) | stat: -rw-r--r-- 1,551 bytes parent folder | download | duplicates (2)
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
47
48
49
50
51
52
53
54
package machine

import (
	"github.com/containers/common/pkg/config"
	. "github.com/onsi/ginkgo/v2"
	"github.com/onsi/gomega"
)

var _ = Describe("Machine", func() {
	BeforeEach(func() {
		// disable normal init for testing
		markerSync.Do(func() {})

		// ensure legacy flag is off
		config, _ := config.Default()
		//nolint:staticcheck //lint:ignore SA1019 deprecated call
		config.Engine.MachineEnabled = false
	})

	It("not a machine", func() {
		loadMachineMarker("testdata/does-not-exist")

		gomega.Expect(IsPodmanMachine()).To(gomega.BeFalse())
		gomega.Expect(MachineHostType()).To(gomega.BeEmpty())
		gomega.Expect(IsGvProxyBased()).To(gomega.BeFalse())
	})

	It("generic machine", func() {
		loadMachineMarker("testdata/empty-machine")

		gomega.Expect(IsPodmanMachine()).To(gomega.BeTrue())
		gomega.Expect(MachineHostType()).To(gomega.BeEmpty())
		gomega.Expect(IsGvProxyBased()).To(gomega.BeTrue())
	})

	It("wsl machine", func() {
		loadMachineMarker("testdata/wsl-machine")

		gomega.Expect(IsPodmanMachine()).To(gomega.BeTrue())
		gomega.Expect(MachineHostType()).To(gomega.Equal(Wsl))
		gomega.Expect(IsGvProxyBased()).To(gomega.BeFalse())
	})

	It("legacy config machine", func() {
		config, _ := config.Default()
		//nolint:staticcheck //lint:ignore SA1019 deprecated call
		config.Engine.MachineEnabled = true
		loadMachineMarker("testdata/does-not-exist")

		gomega.Expect(IsPodmanMachine()).To(gomega.BeTrue())
		gomega.Expect(MachineHostType()).To(gomega.BeEmpty())
		gomega.Expect(IsGvProxyBased()).To(gomega.BeTrue())
	})
})