aboutsummaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-04-05 22:24:15 +0200
committerGitHub <noreply@github.com>2021-04-05 22:24:15 +0200
commit2b13c5d92aa64165aa08b4adc96d3324dc9988ec (patch)
tree3f2fcd095bc6379edd23a845db35820a30c865d3 /pkg
parent8d411a876c2b0ebae4a77a00fcb216d9058f89f0 (diff)
parent7ec8760cbf379ea5b74f96d0a5a6ca81e0e7b50a (diff)
downloadpodman-2b13c5d92aa64165aa08b4adc96d3324dc9988ec.tar.gz
podman-2b13c5d92aa64165aa08b4adc96d3324dc9988ec.tar.bz2
podman-2b13c5d92aa64165aa08b4adc96d3324dc9988ec.zip
Merge pull request #9938 from jmguzik/network-bindings-initial-tests
Initial network bindings tests
Diffstat (limited to 'pkg')
-rw-r--r--pkg/bindings/test/networks_test.go72
1 files changed, 72 insertions, 0 deletions
diff --git a/pkg/bindings/test/networks_test.go b/pkg/bindings/test/networks_test.go
new file mode 100644
index 000000000..ef20235ae
--- /dev/null
+++ b/pkg/bindings/test/networks_test.go
@@ -0,0 +1,72 @@
+package test_bindings
+
+import (
+ "context"
+ "net/http"
+ "time"
+
+ "github.com/containers/podman/v3/pkg/bindings"
+ "github.com/containers/podman/v3/pkg/bindings/network"
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+ "github.com/onsi/gomega/gexec"
+)
+
+var _ = Describe("Podman networks", func() {
+ var (
+ bt *bindingTest
+ s *gexec.Session
+ connText context.Context
+ err error
+ )
+
+ BeforeEach(func() {
+
+ bt = newBindingTest()
+ bt.RestoreImagesFromCache()
+ s = bt.startAPIService()
+ time.Sleep(1 * time.Second)
+ connText, err = bindings.NewConnection(context.Background(), bt.sock)
+ Expect(err).To(BeNil())
+ _, err = network.Prune(connText, &network.PruneOptions{})
+ Expect(err).To(BeNil())
+ })
+
+ AfterEach(func() {
+ s.Kill()
+ bt.cleanup()
+ })
+
+ It("create network", func() {
+ // create a network with blank config should work
+ _, err = network.Create(connText, &network.CreateOptions{})
+ Expect(err).To(BeNil())
+
+ name := "foobar"
+ opts := network.CreateOptions{
+ Name: &name,
+ }
+
+ report, err := network.Create(connText, &opts)
+ Expect(err).To(BeNil())
+ Expect(report.Filename).To(ContainSubstring(name))
+
+ // create network with same name should 500
+ _, err = network.Create(connText, &opts)
+ Expect(err).ToNot(BeNil())
+ code, _ := bindings.CheckResponseCode(err)
+ Expect(code).To(BeNumerically("==", http.StatusInternalServerError))
+ })
+
+ It("inspect network", func() {
+ name := "foobar"
+ opts := network.CreateOptions{
+ Name: &name,
+ }
+ _, err = network.Create(connText, &opts)
+ Expect(err).To(BeNil())
+ data, err := network.Inspect(connText, name, nil)
+ Expect(err).To(BeNil())
+ Expect(data[0]["name"]).To(Equal(name))
+ })
+})