summaryrefslogtreecommitdiff
path: root/pkg/bindings/test/system_test.go
blob: 3abc26b345d294fa313c0a8ddf643b1819200c05 (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 test_bindings

import (
	"time"

	"github.com/containers/libpod/pkg/api/handlers"
	"github.com/containers/libpod/pkg/bindings/system"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"github.com/onsi/gomega/gexec"
)

var _ = Describe("Podman system", 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("podman events", func() {
		eChan := make(chan handlers.Event, 1)
		var messages []handlers.Event
		cancelChan := make(chan bool, 1)
		go func() {
			for e := range eChan {
				messages = append(messages, e)
			}
		}()
		go func() {
			system.Events(bt.conn, eChan, cancelChan, nil, nil, nil)
		}()

		_, err := bt.RunTopContainer(nil, nil, nil)
		Expect(err).To(BeNil())
		cancelChan <- true
		Expect(len(messages)).To(BeNumerically("==", 3))
	})
})