aboutsummaryrefslogtreecommitdiff
path: root/pkg/bindings/test/generator_test.go
blob: 7dc91b153902f805d6516c863edf2d7c598d610e (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
47
48
49
50
51
package bindings_test

import (
	"github.com/containers/podman/v4/pkg/bindings/containers"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	. "github.com/onsi/gomega/gstruct"
)

var _ = Describe("Podman API Bindings", func() {
	boxedTrue, boxedFalse := new(bool), new(bool)
	*boxedTrue = true
	*boxedFalse = false

	It("verify simple setters", func() {
		boxedString := new(string)
		*boxedString = "Test"

		actual := new(containers.AttachOptions).
			WithDetachKeys("Test").WithLogs(true).WithStream(false)

		Expect(*actual).To(MatchAllFields(Fields{
			"DetachKeys": Equal(boxedString),
			"Logs":       Equal(boxedTrue),
			"Stream":     Equal(boxedFalse),
		}))

		Expect(actual.GetDetachKeys()).To(Equal("Test"))
		Expect(actual.GetLogs()).To(Equal(true))
		Expect(actual.GetStream()).To(Equal(false))
	})

	It("verify composite setters", func() {
		boxedInt := new(int)
		*boxedInt = 50

		actual := new(containers.ListOptions).
			WithFilters(map[string][]string{"Test": {"Test Filter"}}).
			WithLast(50)

		Expect(*actual).To(MatchAllFields(Fields{
			"All":       BeNil(),
			"External":  BeNil(),
			"Filters":   HaveKeyWithValue("Test", []string{"Test Filter"}),
			"Last":      Equal(boxedInt),
			"Namespace": BeNil(),
			"Size":      BeNil(),
			"Sync":      BeNil(),
		}))
	})
})