mirror of
https://github.com/containers/podman.git
synced 2025-05-31 07:27:13 +08:00

add go-bindings for logs and events. tests were also added. Signed-off-by: Brent Baude <bbaude@redhat.com>
52 lines
1022 B
Go
52 lines
1022 B
Go
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))
|
|
})
|
|
})
|