aboutsummaryrefslogtreecommitdiff
path: root/pkg/bindings/test/create_test.go
blob: 7fb69ddb7934f7c3a2d7f6d56958d8b7a227ab7d (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
package test_bindings

import (
	"time"

	"github.com/containers/libpod/v2/pkg/bindings/containers"
	"github.com/containers/libpod/v2/pkg/specgen"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"github.com/onsi/gomega/gexec"
)

var _ = Describe("Create containers ", func() {
	var (
		bt *bindingTest
		s  *gexec.Session
	)

	BeforeEach(func() {
		bt = newBindingTest()
		bt.RestoreImagesFromCache()
		s = bt.startAPIService()
		time.Sleep(1 * time.Second)
		err := bt.NewConnection()
		Expect(err).To(BeNil())
	})

	AfterEach(func() {
		s.Kill()
		bt.cleanup()
	})

	It("create a container running top", func() {
		s := specgen.NewSpecGenerator(alpine.name, false)
		s.Command = []string{"top"}
		s.Terminal = true
		s.Name = "top"
		ctr, err := containers.CreateWithSpec(bt.conn, s)
		Expect(err).To(BeNil())
		data, err := containers.Inspect(bt.conn, ctr.ID, nil)
		Expect(err).To(BeNil())
		Expect(data.Name).To(Equal("top"))
		err = containers.Start(bt.conn, ctr.ID, nil)
		Expect(err).To(BeNil())
		data, err = containers.Inspect(bt.conn, ctr.ID, nil)
		Expect(err).To(BeNil())
		Expect(data.State.Status).To(Equal("running"))
	})

})