summaryrefslogtreecommitdiff
path: root/pkg/bindings/test
diff options
context:
space:
mode:
authorJhon Honce <jhonce@redhat.com>2021-09-13 14:29:22 -0700
committerMatthew Heon <mheon@redhat.com>2021-09-16 09:42:14 -0400
commit74bc365eb6f036a87313ffe5acd3561d3c44638f (patch)
treea758b7fc4fe7e35c1cfd344c4d432e75160b50fe /pkg/bindings/test
parente37883f13e6f9e659a044eaa5dba46bab166e3a6 (diff)
downloadpodman-74bc365eb6f036a87313ffe5acd3561d3c44638f.tar.gz
podman-74bc365eb6f036a87313ffe5acd3561d3c44638f.tar.bz2
podman-74bc365eb6f036a87313ffe5acd3561d3c44638f.zip
Enhance bindings for IDE hints
* Follow https://pkg.go.dev/cmd/go#hdr-Generate_Go_files_by_processing_source for leading comment * Add godoc strings for all exposed methods for IDE support * Copy field godoc strings into generated code as function godoc string * Remove unused/unnecessary fields from generator.go structures * Cleanup code regarding template usage Signed-off-by: Jhon Honce <jhonce@redhat.com>
Diffstat (limited to 'pkg/bindings/test')
-rw-r--r--pkg/bindings/test/generator_test.go51
1 files changed, 51 insertions, 0 deletions
diff --git a/pkg/bindings/test/generator_test.go b/pkg/bindings/test/generator_test.go
new file mode 100644
index 000000000..d04cc10f9
--- /dev/null
+++ b/pkg/bindings/test/generator_test.go
@@ -0,0 +1,51 @@
+package test_bindings
+
+import (
+ "github.com/containers/podman/v3/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(),
+ }))
+ })
+})