ginkgo tests: apply ginkgolinter fixes

I found the ginkgolinter[1] by accident, this looks for not optimal
matching and suggest how to do it better.

Overall these fixes seem to be all correct and they will give much
better error messages when something fails.
Check out the repo to see what the linter reports.

[1] https://github.com/nunnatsa/ginkgolinter

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
Paul Holzinger 2022-11-24 17:59:50 +01:00
parent c7827957a4
commit 2ddf1c5cbd
No known key found for this signature in database
GPG Key ID: EB145DD938A3CAF2
88 changed files with 1210 additions and 1210 deletions

View File

@ -26,21 +26,21 @@ var _ = Describe("Podman images", func() {
// the test. Otherwise, the registry is not reachable for // the test. Otherwise, the registry is not reachable for
// currently unknown reasons. // currently unknown reasons.
registry, err = podmanRegistry.Start() registry, err = podmanRegistry.Start()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
bt = newBindingTest() bt = newBindingTest()
bt.RestoreImagesFromCache() bt.RestoreImagesFromCache()
s = bt.startAPIService() s = bt.startAPIService()
time.Sleep(1 * time.Second) time.Sleep(1 * time.Second)
err := bt.NewConnection() err := bt.NewConnection()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
}) })
AfterEach(func() { AfterEach(func() {
s.Kill() s.Kill()
bt.cleanup() bt.cleanup()
err := registry.Stop() err := registry.Stop()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
}) })
// Test using credentials. // Test using credentials.
@ -52,19 +52,19 @@ var _ = Describe("Podman images", func() {
// Tag the alpine image and verify it has worked. // Tag the alpine image and verify it has worked.
err = images.Tag(bt.conn, alpine.shortName, imageTag, imageRep, nil) err = images.Tag(bt.conn, alpine.shortName, imageTag, imageRep, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
_, err = images.GetImage(bt.conn, imageRef, nil) _, err = images.GetImage(bt.conn, imageRef, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// Now push the image. // Now push the image.
pushOpts := new(images.PushOptions) pushOpts := new(images.PushOptions)
err = images.Push(bt.conn, imageRef, imageRef, pushOpts.WithUsername(registry.User).WithPassword(registry.Password).WithSkipTLSVerify(true)) err = images.Push(bt.conn, imageRef, imageRef, pushOpts.WithUsername(registry.User).WithPassword(registry.Password).WithSkipTLSVerify(true))
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// Now pull the image. // Now pull the image.
pullOpts := new(images.PullOptions) pullOpts := new(images.PullOptions)
_, err = images.Pull(bt.conn, imageRef, pullOpts.WithSkipTLSVerify(true).WithPassword(registry.Password).WithUsername(registry.User)) _, err = images.Pull(bt.conn, imageRef, pullOpts.WithSkipTLSVerify(true).WithPassword(registry.Password).WithUsername(registry.User))
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
}) })
// Test using authfile. // Test using authfile.
@ -76,11 +76,11 @@ var _ = Describe("Podman images", func() {
// Create a temporary authentication file. // Create a temporary authentication file.
tmpFile, err := os.CreateTemp("", "auth.json.") tmpFile, err := os.CreateTemp("", "auth.json.")
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
_, err = tmpFile.Write([]byte{'{', '}'}) _, err = tmpFile.Write([]byte{'{', '}'})
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
err = tmpFile.Close() err = tmpFile.Close()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
authFilePath := tmpFile.Name() authFilePath := tmpFile.Name()
@ -98,28 +98,28 @@ var _ = Describe("Podman images", func() {
Stdout: os.Stdout, Stdout: os.Stdout,
} }
err = auth.Login(bt.conn, &sys, &loginOptions, []string{imageRep}) err = auth.Login(bt.conn, &sys, &loginOptions, []string{imageRep})
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// Tag the alpine image and verify it has worked. // Tag the alpine image and verify it has worked.
err = images.Tag(bt.conn, alpine.shortName, imageTag, imageRep, nil) err = images.Tag(bt.conn, alpine.shortName, imageTag, imageRep, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
_, err = images.GetImage(bt.conn, imageRef, nil) _, err = images.GetImage(bt.conn, imageRef, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// Now push the image. // Now push the image.
pushOpts := new(images.PushOptions) pushOpts := new(images.PushOptions)
err = images.Push(bt.conn, imageRef, imageRef, pushOpts.WithAuthfile(authFilePath).WithSkipTLSVerify(true)) err = images.Push(bt.conn, imageRef, imageRef, pushOpts.WithAuthfile(authFilePath).WithSkipTLSVerify(true))
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// Now pull the image. // Now pull the image.
pullOpts := new(images.PullOptions) pullOpts := new(images.PullOptions)
_, err = images.Pull(bt.conn, imageRef, pullOpts.WithAuthfile(authFilePath).WithSkipTLSVerify(true)) _, err = images.Pull(bt.conn, imageRef, pullOpts.WithAuthfile(authFilePath).WithSkipTLSVerify(true))
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// Last, but not least, exercise search. // Last, but not least, exercise search.
searchOptions := new(images.SearchOptions) searchOptions := new(images.SearchOptions)
_, err = images.Search(bt.conn, imageRef, searchOptions.WithSkipTLSVerify(true).WithAuthfile(authFilePath)) _, err = images.Search(bt.conn, imageRef, searchOptions.WithSkipTLSVerify(true).WithAuthfile(authFilePath))
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
}) })
}) })

View File

@ -23,7 +23,7 @@ var _ = Describe("Podman connection", func() {
s = bt.startAPIService() s = bt.startAPIService()
time.Sleep(1 * time.Second) time.Sleep(1 * time.Second)
err := bt.NewConnection() err := bt.NewConnection()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
}) })
AfterEach(func() { AfterEach(func() {
@ -41,7 +41,7 @@ var _ = Describe("Podman connection", func() {
It("cancel request in flight reports cancelled context", func() { It("cancel request in flight reports cancelled context", func() {
var name = "top" var name = "top"
_, err := bt.RunTopContainer(&name, nil) _, err := bt.RunTopContainer(&name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
errChan := make(chan error) errChan := make(chan error)
ctx, cancel := context.WithCancel(bt.conn) ctx, cancel := context.WithCancel(bt.conn)

View File

@ -28,7 +28,7 @@ var _ = Describe("Podman containers ", func() {
s = bt.startAPIService() s = bt.startAPIService()
time.Sleep(1 * time.Second) time.Sleep(1 * time.Second)
err := bt.NewConnection() err := bt.NewConnection()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
}) })
AfterEach(func() { AfterEach(func() {
@ -39,7 +39,7 @@ var _ = Describe("Podman containers ", func() {
It("podman pause a bogus container", func() { It("podman pause a bogus container", func() {
// Pausing bogus container should return 404 // Pausing bogus container should return 404
err = containers.Pause(bt.conn, "foobar", nil) err = containers.Pause(bt.conn, "foobar", nil)
Expect(err).ToNot(BeNil()) Expect(err).To(HaveOccurred())
code, _ := bindings.CheckResponseCode(err) code, _ := bindings.CheckResponseCode(err)
Expect(code).To(BeNumerically("==", http.StatusNotFound)) Expect(code).To(BeNumerically("==", http.StatusNotFound))
}) })
@ -47,7 +47,7 @@ var _ = Describe("Podman containers ", func() {
It("podman unpause a bogus container", func() { It("podman unpause a bogus container", func() {
// Unpausing bogus container should return 404 // Unpausing bogus container should return 404
err = containers.Unpause(bt.conn, "foobar", nil) err = containers.Unpause(bt.conn, "foobar", nil)
Expect(err).ToNot(BeNil()) Expect(err).To(HaveOccurred())
code, _ := bindings.CheckResponseCode(err) code, _ := bindings.CheckResponseCode(err)
Expect(code).To(BeNumerically("==", http.StatusNotFound)) Expect(code).To(BeNumerically("==", http.StatusNotFound))
}) })
@ -56,13 +56,13 @@ var _ = Describe("Podman containers ", func() {
// Pausing by name should work // Pausing by name should work
var name = "top" var name = "top"
_, err := bt.RunTopContainer(&name, nil) _, err := bt.RunTopContainer(&name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
err = containers.Pause(bt.conn, name, nil) err = containers.Pause(bt.conn, name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// Ensure container is paused // Ensure container is paused
data, err := containers.Inspect(bt.conn, name, nil) data, err := containers.Inspect(bt.conn, name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(data.State.Status).To(Equal("paused")) Expect(data.State.Status).To(Equal("paused"))
}) })
@ -70,13 +70,13 @@ var _ = Describe("Podman containers ", func() {
// Pausing by id should work // Pausing by id should work
var name = "top" var name = "top"
cid, err := bt.RunTopContainer(&name, nil) cid, err := bt.RunTopContainer(&name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
err = containers.Pause(bt.conn, cid, nil) err = containers.Pause(bt.conn, cid, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// Ensure container is paused // Ensure container is paused
data, err := containers.Inspect(bt.conn, cid, nil) data, err := containers.Inspect(bt.conn, cid, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(data.State.Status).To(Equal("paused")) Expect(data.State.Status).To(Equal("paused"))
}) })
@ -84,15 +84,15 @@ var _ = Describe("Podman containers ", func() {
// Unpausing by name should work // Unpausing by name should work
var name = "top" var name = "top"
_, err := bt.RunTopContainer(&name, nil) _, err := bt.RunTopContainer(&name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
err = containers.Pause(bt.conn, name, nil) err = containers.Pause(bt.conn, name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
err = containers.Unpause(bt.conn, name, nil) err = containers.Unpause(bt.conn, name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// Ensure container is unpaused // Ensure container is unpaused
data, err := containers.Inspect(bt.conn, name, nil) data, err := containers.Inspect(bt.conn, name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(data.State.Status).To(Equal("running")) Expect(data.State.Status).To(Equal("running"))
}) })
@ -100,19 +100,19 @@ var _ = Describe("Podman containers ", func() {
// Unpausing by ID should work // Unpausing by ID should work
var name = "top" var name = "top"
_, err := bt.RunTopContainer(&name, nil) _, err := bt.RunTopContainer(&name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// Pause by name // Pause by name
err = containers.Pause(bt.conn, name, nil) err = containers.Pause(bt.conn, name, nil)
Expect(err).To(BeNil(), "error from containers.Pause()") Expect(err).ToNot(HaveOccurred(), "error from containers.Pause()")
// paused := "paused" // paused := "paused"
// _, err = containers.Wait(bt.conn, cid, &paused) // _, err = containers.Wait(bt.conn, cid, &paused)
// Expect(err).To(BeNil()) // Expect(err).To(BeNil())
err = containers.Unpause(bt.conn, name, nil) err = containers.Unpause(bt.conn, name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// Ensure container is unpaused // Ensure container is unpaused
data, err := containers.Inspect(bt.conn, name, nil) data, err := containers.Inspect(bt.conn, name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(data.State.Status).To(Equal("running")) Expect(data.State.Status).To(Equal("running"))
}) })
@ -120,11 +120,11 @@ var _ = Describe("Podman containers ", func() {
// Pausing a paused container by name should fail // Pausing a paused container by name should fail
var name = "top" var name = "top"
_, err := bt.RunTopContainer(&name, nil) _, err := bt.RunTopContainer(&name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
err = containers.Pause(bt.conn, name, nil) err = containers.Pause(bt.conn, name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
err = containers.Pause(bt.conn, name, nil) err = containers.Pause(bt.conn, name, nil)
Expect(err).ToNot(BeNil()) Expect(err).To(HaveOccurred())
code, _ := bindings.CheckResponseCode(err) code, _ := bindings.CheckResponseCode(err)
Expect(code).To(BeNumerically("==", http.StatusInternalServerError)) Expect(code).To(BeNumerically("==", http.StatusInternalServerError))
}) })
@ -133,11 +133,11 @@ var _ = Describe("Podman containers ", func() {
// Pausing a paused container by id should fail // Pausing a paused container by id should fail
var name = "top" var name = "top"
cid, err := bt.RunTopContainer(&name, nil) cid, err := bt.RunTopContainer(&name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
err = containers.Pause(bt.conn, cid, nil) err = containers.Pause(bt.conn, cid, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
err = containers.Pause(bt.conn, cid, nil) err = containers.Pause(bt.conn, cid, nil)
Expect(err).ToNot(BeNil()) Expect(err).To(HaveOccurred())
code, _ := bindings.CheckResponseCode(err) code, _ := bindings.CheckResponseCode(err)
Expect(code).To(BeNumerically("==", http.StatusInternalServerError)) Expect(code).To(BeNumerically("==", http.StatusInternalServerError))
}) })
@ -146,11 +146,11 @@ var _ = Describe("Podman containers ", func() {
// Pausing a stopped container by name should fail // Pausing a stopped container by name should fail
var name = "top" var name = "top"
_, err := bt.RunTopContainer(&name, nil) _, err := bt.RunTopContainer(&name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
err = containers.Stop(bt.conn, name, nil) err = containers.Stop(bt.conn, name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
err = containers.Pause(bt.conn, name, nil) err = containers.Pause(bt.conn, name, nil)
Expect(err).ToNot(BeNil()) Expect(err).To(HaveOccurred())
code, _ := bindings.CheckResponseCode(err) code, _ := bindings.CheckResponseCode(err)
Expect(code).To(BeNumerically("==", http.StatusInternalServerError)) Expect(code).To(BeNumerically("==", http.StatusInternalServerError))
}) })
@ -159,11 +159,11 @@ var _ = Describe("Podman containers ", func() {
// Pausing a stopped container by id should fail // Pausing a stopped container by id should fail
var name = "top" var name = "top"
cid, err := bt.RunTopContainer(&name, nil) cid, err := bt.RunTopContainer(&name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
err = containers.Stop(bt.conn, cid, nil) err = containers.Stop(bt.conn, cid, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
err = containers.Pause(bt.conn, cid, nil) err = containers.Pause(bt.conn, cid, nil)
Expect(err).ToNot(BeNil()) Expect(err).To(HaveOccurred())
code, _ := bindings.CheckResponseCode(err) code, _ := bindings.CheckResponseCode(err)
Expect(code).To(BeNumerically("==", http.StatusInternalServerError)) Expect(code).To(BeNumerically("==", http.StatusInternalServerError))
}) })
@ -172,11 +172,11 @@ var _ = Describe("Podman containers ", func() {
// Removing a paused container without force should fail // Removing a paused container without force should fail
var name = "top" var name = "top"
cid, err := bt.RunTopContainer(&name, nil) cid, err := bt.RunTopContainer(&name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
err = containers.Pause(bt.conn, cid, nil) err = containers.Pause(bt.conn, cid, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
_, err = containers.Remove(bt.conn, cid, nil) _, err = containers.Remove(bt.conn, cid, nil)
Expect(err).ToNot(BeNil()) Expect(err).To(HaveOccurred())
code, _ := bindings.CheckResponseCode(err) code, _ := bindings.CheckResponseCode(err)
Expect(code).To(BeNumerically("==", http.StatusInternalServerError)) Expect(code).To(BeNumerically("==", http.StatusInternalServerError))
}) })
@ -185,24 +185,24 @@ var _ = Describe("Podman containers ", func() {
// Removing a paused container with force should work // Removing a paused container with force should work
var name = "top" var name = "top"
cid, err := bt.RunTopContainer(&name, nil) cid, err := bt.RunTopContainer(&name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
err = containers.Pause(bt.conn, cid, nil) err = containers.Pause(bt.conn, cid, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
rmResponse, err := containers.Remove(bt.conn, cid, new(containers.RemoveOptions).WithForce(true)) rmResponse, err := containers.Remove(bt.conn, cid, new(containers.RemoveOptions).WithForce(true))
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(len(reports.RmReportsErrs(rmResponse))).To(Equal(0)) Expect(reports.RmReportsErrs(rmResponse)).To(BeEmpty())
Expect(len(reports.RmReportsIds(rmResponse))).To(Equal(1)) Expect(reports.RmReportsIds(rmResponse)).To(HaveLen(1))
}) })
It("podman stop a paused container by name", func() { It("podman stop a paused container by name", func() {
// Stopping a paused container by name should fail // Stopping a paused container by name should fail
var name = "top" var name = "top"
_, err := bt.RunTopContainer(&name, nil) _, err := bt.RunTopContainer(&name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
err = containers.Pause(bt.conn, name, nil) err = containers.Pause(bt.conn, name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
err = containers.Stop(bt.conn, name, nil) err = containers.Stop(bt.conn, name, nil)
Expect(err).ToNot(BeNil()) Expect(err).To(HaveOccurred())
code, _ := bindings.CheckResponseCode(err) code, _ := bindings.CheckResponseCode(err)
Expect(code).To(BeNumerically("==", http.StatusInternalServerError)) Expect(code).To(BeNumerically("==", http.StatusInternalServerError))
}) })
@ -211,11 +211,11 @@ var _ = Describe("Podman containers ", func() {
// Stopping a paused container by id should fail // Stopping a paused container by id should fail
var name = "top" var name = "top"
cid, err := bt.RunTopContainer(&name, nil) cid, err := bt.RunTopContainer(&name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
err = containers.Pause(bt.conn, cid, nil) err = containers.Pause(bt.conn, cid, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
err = containers.Stop(bt.conn, cid, nil) err = containers.Stop(bt.conn, cid, nil)
Expect(err).ToNot(BeNil()) Expect(err).To(HaveOccurred())
code, _ := bindings.CheckResponseCode(err) code, _ := bindings.CheckResponseCode(err)
Expect(code).To(BeNumerically("==", http.StatusInternalServerError)) Expect(code).To(BeNumerically("==", http.StatusInternalServerError))
}) })
@ -224,13 +224,13 @@ var _ = Describe("Podman containers ", func() {
// Stopping a running container by name should work // Stopping a running container by name should work
var name = "top" var name = "top"
_, err := bt.RunTopContainer(&name, nil) _, err := bt.RunTopContainer(&name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
err = containers.Stop(bt.conn, name, nil) err = containers.Stop(bt.conn, name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// Ensure container is stopped // Ensure container is stopped
data, err := containers.Inspect(bt.conn, name, nil) data, err := containers.Inspect(bt.conn, name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(isStopped(data.State.Status)).To(BeTrue()) Expect(isStopped(data.State.Status)).To(BeTrue())
}) })
@ -238,13 +238,13 @@ var _ = Describe("Podman containers ", func() {
// Stopping a running container by ID should work // Stopping a running container by ID should work
var name = "top" var name = "top"
cid, err := bt.RunTopContainer(&name, nil) cid, err := bt.RunTopContainer(&name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
err = containers.Stop(bt.conn, cid, nil) err = containers.Stop(bt.conn, cid, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// Ensure container is stopped // Ensure container is stopped
data, err := containers.Inspect(bt.conn, name, nil) data, err := containers.Inspect(bt.conn, name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(isStopped(data.State.Status)).To(BeTrue()) Expect(isStopped(data.State.Status)).To(BeTrue())
}) })
@ -254,13 +254,13 @@ var _ = Describe("Podman containers ", func() {
exitCode int32 = -1 exitCode int32 = -1
) )
_, err := containers.Wait(bt.conn, "foobar", nil) _, err := containers.Wait(bt.conn, "foobar", nil)
Expect(err).ToNot(BeNil()) Expect(err).To(HaveOccurred())
code, _ := bindings.CheckResponseCode(err) code, _ := bindings.CheckResponseCode(err)
Expect(code).To(BeNumerically("==", http.StatusNotFound)) Expect(code).To(BeNumerically("==", http.StatusNotFound))
errChan := make(chan error) errChan := make(chan error)
_, err = bt.RunTopContainer(&name, nil) _, err = bt.RunTopContainer(&name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
go func() { go func() {
defer GinkgoRecover() defer GinkgoRecover()
exitCode, err = containers.Wait(bt.conn, name, nil) exitCode, err = containers.Wait(bt.conn, name, nil)
@ -268,9 +268,9 @@ var _ = Describe("Podman containers ", func() {
close(errChan) close(errChan)
}() }()
err = containers.Stop(bt.conn, name, nil) err = containers.Stop(bt.conn, name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
wait := <-errChan wait := <-errChan
Expect(wait).To(BeNil()) Expect(wait).ToNot(HaveOccurred())
Expect(exitCode).To(BeNumerically("==", 143)) Expect(exitCode).To(BeNumerically("==", 143))
}) })
@ -283,7 +283,7 @@ var _ = Describe("Podman containers ", func() {
) )
errChan := make(chan error) errChan := make(chan error)
_, err := bt.RunTopContainer(&name, nil) _, err := bt.RunTopContainer(&name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
go func() { go func() {
defer GinkgoRecover() defer GinkgoRecover()
exitCode, err = containers.Wait(bt.conn, name, new(containers.WaitOptions).WithCondition([]define.ContainerStatus{pause})) exitCode, err = containers.Wait(bt.conn, name, new(containers.WaitOptions).WithCondition([]define.ContainerStatus{pause}))
@ -291,9 +291,9 @@ var _ = Describe("Podman containers ", func() {
close(errChan) close(errChan)
}() }()
err = containers.Pause(bt.conn, name, nil) err = containers.Pause(bt.conn, name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
wait := <-errChan wait := <-errChan
Expect(wait).To(BeNil()) Expect(wait).ToNot(HaveOccurred())
Expect(exitCode).To(BeNumerically("==", -1)) Expect(exitCode).To(BeNumerically("==", -1))
unpauseErrChan := make(chan error) unpauseErrChan := make(chan error)
@ -305,9 +305,9 @@ var _ = Describe("Podman containers ", func() {
close(unpauseErrChan) close(unpauseErrChan)
}() }()
err = containers.Unpause(bt.conn, name, nil) err = containers.Unpause(bt.conn, name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
unPausewait := <-unpauseErrChan unPausewait := <-unpauseErrChan
Expect(unPausewait).To(BeNil()) Expect(unPausewait).ToNot(HaveOccurred())
Expect(exitCode).To(BeNumerically("==", -1)) Expect(exitCode).To(BeNumerically("==", -1))
}) })
@ -316,16 +316,16 @@ var _ = Describe("Podman containers ", func() {
// bogus name should result in 404 // bogus name should result in 404
_, err := containers.RunHealthCheck(bt.conn, "foobar", nil) _, err := containers.RunHealthCheck(bt.conn, "foobar", nil)
Expect(err).ToNot(BeNil()) Expect(err).To(HaveOccurred())
code, _ := bindings.CheckResponseCode(err) code, _ := bindings.CheckResponseCode(err)
Expect(code).To(BeNumerically("==", http.StatusNotFound)) Expect(code).To(BeNumerically("==", http.StatusNotFound))
// a container that has no healthcheck should be a 409 // a container that has no healthcheck should be a 409
var name = "top" var name = "top"
_, err = bt.RunTopContainer(&name, nil) _, err = bt.RunTopContainer(&name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
_, err = containers.RunHealthCheck(bt.conn, name, nil) _, err = containers.RunHealthCheck(bt.conn, name, nil)
Expect(err).ToNot(BeNil()) Expect(err).To(HaveOccurred())
code, _ = bindings.CheckResponseCode(err) code, _ = bindings.CheckResponseCode(err)
Expect(code).To(BeNumerically("==", http.StatusConflict)) Expect(code).To(BeNumerically("==", http.StatusConflict))
@ -363,12 +363,12 @@ var _ = Describe("Podman containers ", func() {
s.Terminal = true s.Terminal = true
s.Command = []string{"date", "-R"} s.Command = []string{"date", "-R"}
r, err := containers.CreateWithSpec(bt.conn, s, nil) r, err := containers.CreateWithSpec(bt.conn, s, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
err = containers.Start(bt.conn, r.ID, nil) err = containers.Start(bt.conn, r.ID, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
_, err = containers.Wait(bt.conn, r.ID, nil) _, err = containers.Wait(bt.conn, r.ID, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
opts := new(containers.LogOptions).WithStdout(true).WithFollow(true) opts := new(containers.LogOptions).WithStdout(true).WithFollow(true)
go func() { go func() {
@ -386,19 +386,19 @@ var _ = Describe("Podman containers ", func() {
It("podman top", func() { It("podman top", func() {
var name = "top" var name = "top"
cid, err := bt.RunTopContainer(&name, nil) cid, err := bt.RunTopContainer(&name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// By name // By name
_, err = containers.Top(bt.conn, name, nil) _, err = containers.Top(bt.conn, name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// By id // By id
_, err = containers.Top(bt.conn, cid, nil) _, err = containers.Top(bt.conn, cid, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// With descriptors // With descriptors
output, err := containers.Top(bt.conn, cid, new(containers.TopOptions).WithDescriptors([]string{"user", "pid", "hpid"})) output, err := containers.Top(bt.conn, cid, new(containers.TopOptions).WithDescriptors([]string{"user", "pid", "hpid"}))
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
header := strings.Split(output[0], "\t") header := strings.Split(output[0], "\t")
for _, d := range []string{"USER", "PID", "HPID"} { for _, d := range []string{"USER", "PID", "HPID"} {
Expect(d).To(BeElementOf(header)) Expect(d).To(BeElementOf(header))
@ -406,17 +406,17 @@ var _ = Describe("Podman containers ", func() {
// With bogus ID // With bogus ID
_, err = containers.Top(bt.conn, "IdoNotExist", nil) _, err = containers.Top(bt.conn, "IdoNotExist", nil)
Expect(err).ToNot(BeNil()) Expect(err).To(HaveOccurred())
// With bogus descriptors // With bogus descriptors
_, err = containers.Top(bt.conn, cid, new(containers.TopOptions).WithDescriptors([]string{"Me,Neither"})) _, err = containers.Top(bt.conn, cid, new(containers.TopOptions).WithDescriptors([]string{"Me,Neither"}))
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
}) })
It("podman bogus container does not exist in local storage", func() { It("podman bogus container does not exist in local storage", func() {
// Bogus container existence check should fail // Bogus container existence check should fail
containerExists, err := containers.Exists(bt.conn, "foobar", nil) containerExists, err := containers.Exists(bt.conn, "foobar", nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(containerExists).To(BeFalse()) Expect(containerExists).To(BeFalse())
}) })
@ -424,9 +424,9 @@ var _ = Describe("Podman containers ", func() {
// Container existence check by name should work // Container existence check by name should work
var name = "top" var name = "top"
_, err := bt.RunTopContainer(&name, nil) _, err := bt.RunTopContainer(&name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
containerExists, err := containers.Exists(bt.conn, name, nil) containerExists, err := containers.Exists(bt.conn, name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(containerExists).To(BeTrue()) Expect(containerExists).To(BeTrue())
}) })
@ -434,9 +434,9 @@ var _ = Describe("Podman containers ", func() {
// Container existence check by ID should work // Container existence check by ID should work
var name = "top" var name = "top"
cid, err := bt.RunTopContainer(&name, nil) cid, err := bt.RunTopContainer(&name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
containerExists, err := containers.Exists(bt.conn, cid, nil) containerExists, err := containers.Exists(bt.conn, cid, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(containerExists).To(BeTrue()) Expect(containerExists).To(BeTrue())
}) })
@ -444,16 +444,16 @@ var _ = Describe("Podman containers ", func() {
// Container existence check by short ID should work // Container existence check by short ID should work
var name = "top" var name = "top"
cid, err := bt.RunTopContainer(&name, nil) cid, err := bt.RunTopContainer(&name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
containerExists, err := containers.Exists(bt.conn, cid[0:12], nil) containerExists, err := containers.Exists(bt.conn, cid[0:12], nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(containerExists).To(BeTrue()) Expect(containerExists).To(BeTrue())
}) })
It("podman kill bogus container", func() { It("podman kill bogus container", func() {
// Killing bogus container should return 404 // Killing bogus container should return 404
err := containers.Kill(bt.conn, "foobar", new(containers.KillOptions).WithSignal("SIGTERM")) err := containers.Kill(bt.conn, "foobar", new(containers.KillOptions).WithSignal("SIGTERM"))
Expect(err).ToNot(BeNil()) Expect(err).To(HaveOccurred())
code, _ := bindings.CheckResponseCode(err) code, _ := bindings.CheckResponseCode(err)
Expect(code).To(BeNumerically("==", http.StatusNotFound)) Expect(code).To(BeNumerically("==", http.StatusNotFound))
}) })
@ -462,40 +462,40 @@ var _ = Describe("Podman containers ", func() {
// Killing a running container should work // Killing a running container should work
var name = "top" var name = "top"
_, err := bt.RunTopContainer(&name, nil) _, err := bt.RunTopContainer(&name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
err = containers.Kill(bt.conn, name, new(containers.KillOptions).WithSignal("SIGINT")) err = containers.Kill(bt.conn, name, new(containers.KillOptions).WithSignal("SIGINT"))
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
_, err = containers.Exists(bt.conn, name, nil) _, err = containers.Exists(bt.conn, name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
}) })
It("podman kill a running container by ID with SIGTERM", func() { It("podman kill a running container by ID with SIGTERM", func() {
// Killing a running container by ID should work // Killing a running container by ID should work
var name = "top" var name = "top"
cid, err := bt.RunTopContainer(&name, nil) cid, err := bt.RunTopContainer(&name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
err = containers.Kill(bt.conn, cid, new(containers.KillOptions).WithSignal("SIGTERM")) err = containers.Kill(bt.conn, cid, new(containers.KillOptions).WithSignal("SIGTERM"))
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
_, err = containers.Exists(bt.conn, cid, nil) _, err = containers.Exists(bt.conn, cid, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
}) })
It("podman kill a running container by ID with SIGKILL", func() { It("podman kill a running container by ID with SIGKILL", func() {
// Killing a running container by ID with TERM should work // Killing a running container by ID with TERM should work
var name = "top" var name = "top"
cid, err := bt.RunTopContainer(&name, nil) cid, err := bt.RunTopContainer(&name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
err = containers.Kill(bt.conn, cid, new(containers.KillOptions).WithSignal("SIGKILL")) err = containers.Kill(bt.conn, cid, new(containers.KillOptions).WithSignal("SIGKILL"))
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
}) })
It("podman kill a running container by bogus signal", func() { It("podman kill a running container by bogus signal", func() {
// Killing a running container by bogus signal should fail // Killing a running container by bogus signal should fail
var name = "top" var name = "top"
cid, err := bt.RunTopContainer(&name, nil) cid, err := bt.RunTopContainer(&name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
err = containers.Kill(bt.conn, cid, new(containers.KillOptions).WithSignal("foobar")) err = containers.Kill(bt.conn, cid, new(containers.KillOptions).WithSignal("foobar"))
Expect(err).ToNot(BeNil()) Expect(err).To(HaveOccurred())
code, _ := bindings.CheckResponseCode(err) code, _ := bindings.CheckResponseCode(err)
Expect(code).To(BeNumerically("==", http.StatusInternalServerError)) Expect(code).To(BeNumerically("==", http.StatusInternalServerError))
}) })
@ -505,18 +505,18 @@ var _ = Describe("Podman containers ", func() {
var name1 = "first" var name1 = "first"
var name2 = "second" var name2 = "second"
_, err := bt.RunTopContainer(&name1, nil) _, err := bt.RunTopContainer(&name1, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
_, err = bt.RunTopContainer(&name2, nil) _, err = bt.RunTopContainer(&name2, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
containerLatestList, err := containers.List(bt.conn, new(containers.ListOptions).WithLast(1)) containerLatestList, err := containers.List(bt.conn, new(containers.ListOptions).WithLast(1))
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
err = containers.Kill(bt.conn, containerLatestList[0].Names[0], new(containers.KillOptions).WithSignal("SIGTERM")) err = containers.Kill(bt.conn, containerLatestList[0].Names[0], new(containers.KillOptions).WithSignal("SIGTERM"))
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
}) })
It("container init on a bogus container", func() { It("container init on a bogus container", func() {
err := containers.ContainerInit(bt.conn, "doesnotexist", nil) err := containers.ContainerInit(bt.conn, "doesnotexist", nil)
Expect(err).ToNot(BeNil()) Expect(err).To(HaveOccurred())
code, _ := bindings.CheckResponseCode(err) code, _ := bindings.CheckResponseCode(err)
Expect(code).To(BeNumerically("==", http.StatusNotFound)) Expect(code).To(BeNumerically("==", http.StatusNotFound))
}) })
@ -524,110 +524,110 @@ var _ = Describe("Podman containers ", func() {
It("container init", func() { It("container init", func() {
s := specgen.NewSpecGenerator(alpine.name, false) s := specgen.NewSpecGenerator(alpine.name, false)
ctr, err := containers.CreateWithSpec(bt.conn, s, nil) ctr, err := containers.CreateWithSpec(bt.conn, s, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
err = containers.ContainerInit(bt.conn, ctr.ID, nil) err = containers.ContainerInit(bt.conn, ctr.ID, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// trying to init again should be an error // trying to init again should be an error
err = containers.ContainerInit(bt.conn, ctr.ID, nil) err = containers.ContainerInit(bt.conn, ctr.ID, nil)
Expect(err).ToNot(BeNil()) Expect(err).To(HaveOccurred())
}) })
It("podman prune stopped containers", func() { It("podman prune stopped containers", func() {
// Start and stop a container to enter in exited state. // Start and stop a container to enter in exited state.
var name = "top" var name = "top"
_, err := bt.RunTopContainer(&name, nil) _, err := bt.RunTopContainer(&name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
err = containers.Stop(bt.conn, name, nil) err = containers.Stop(bt.conn, name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// Prune container should return no errors and one pruned container ID. // Prune container should return no errors and one pruned container ID.
pruneResponse, err := containers.Prune(bt.conn, nil) pruneResponse, err := containers.Prune(bt.conn, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(len(reports.PruneReportsErrs(pruneResponse))).To(Equal(0)) Expect(reports.PruneReportsErrs(pruneResponse)).To(BeEmpty())
Expect(len(reports.PruneReportsIds(pruneResponse))).To(Equal(1)) Expect(reports.PruneReportsIds(pruneResponse)).To(HaveLen(1))
}) })
It("podman prune stopped containers with filters", func() { It("podman prune stopped containers with filters", func() {
// Start and stop a container to enter in exited state. // Start and stop a container to enter in exited state.
var name = "top" var name = "top"
_, err := bt.RunTopContainer(&name, nil) _, err := bt.RunTopContainer(&name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
err = containers.Stop(bt.conn, name, nil) err = containers.Stop(bt.conn, name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// Invalid filter keys should return error. // Invalid filter keys should return error.
filtersIncorrect := map[string][]string{ filtersIncorrect := map[string][]string{
"status": {"dummy"}, "status": {"dummy"},
} }
_, err = containers.Prune(bt.conn, new(containers.PruneOptions).WithFilters(filtersIncorrect)) _, err = containers.Prune(bt.conn, new(containers.PruneOptions).WithFilters(filtersIncorrect))
Expect(err).ToNot(BeNil()) Expect(err).To(HaveOccurred())
// List filter params should not work with prune. // List filter params should not work with prune.
filtersIncorrect = map[string][]string{ filtersIncorrect = map[string][]string{
"name": {"top"}, "name": {"top"},
} }
_, err = containers.Prune(bt.conn, new(containers.PruneOptions).WithFilters(filtersIncorrect)) _, err = containers.Prune(bt.conn, new(containers.PruneOptions).WithFilters(filtersIncorrect))
Expect(err).ToNot(BeNil()) Expect(err).To(HaveOccurred())
// Mismatched filter params no container should be pruned. // Mismatched filter params no container should be pruned.
filtersIncorrect = map[string][]string{ filtersIncorrect = map[string][]string{
"label": {"xyz"}, "label": {"xyz"},
} }
pruneResponse, err := containers.Prune(bt.conn, new(containers.PruneOptions).WithFilters(filtersIncorrect)) pruneResponse, err := containers.Prune(bt.conn, new(containers.PruneOptions).WithFilters(filtersIncorrect))
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(len(reports.PruneReportsIds(pruneResponse))).To(Equal(0)) Expect(reports.PruneReportsIds(pruneResponse)).To(BeEmpty())
Expect(len(reports.PruneReportsErrs(pruneResponse))).To(Equal(0)) Expect(reports.PruneReportsErrs(pruneResponse)).To(BeEmpty())
// Valid filter params container should be pruned now. // Valid filter params container should be pruned now.
filters := map[string][]string{ filters := map[string][]string{
"until": {"5000000000"}, // Friday, June 11, 2128 "until": {"5000000000"}, // Friday, June 11, 2128
} }
pruneResponse, err = containers.Prune(bt.conn, new(containers.PruneOptions).WithFilters(filters)) pruneResponse, err = containers.Prune(bt.conn, new(containers.PruneOptions).WithFilters(filters))
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(len(reports.PruneReportsErrs(pruneResponse))).To(Equal(0)) Expect(reports.PruneReportsErrs(pruneResponse)).To(BeEmpty())
Expect(len(reports.PruneReportsIds(pruneResponse))).To(Equal(1)) Expect(reports.PruneReportsIds(pruneResponse)).To(HaveLen(1))
}) })
It("podman list containers with until filter", func() { It("podman list containers with until filter", func() {
var name = "top" var name = "top"
_, err := bt.RunTopContainer(&name, nil) _, err := bt.RunTopContainer(&name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
filters := map[string][]string{ filters := map[string][]string{
"until": {"5000000000"}, // Friday, June 11, 2128 "until": {"5000000000"}, // Friday, June 11, 2128
} }
c, err := containers.List(bt.conn, new(containers.ListOptions).WithFilters(filters).WithAll(true)) c, err := containers.List(bt.conn, new(containers.ListOptions).WithFilters(filters).WithAll(true))
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(len(c)).To(Equal(1)) Expect(c).To(HaveLen(1))
filters = map[string][]string{ filters = map[string][]string{
"until": {"500000"}, // Tuesday, January 6, 1970 "until": {"500000"}, // Tuesday, January 6, 1970
} }
c, err = containers.List(bt.conn, new(containers.ListOptions).WithFilters(filters).WithAll(true)) c, err = containers.List(bt.conn, new(containers.ListOptions).WithFilters(filters).WithAll(true))
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(len(c)).To(Equal(0)) Expect(c).To(BeEmpty())
}) })
It("podman prune running containers", func() { It("podman prune running containers", func() {
// Start the container. // Start the container.
var name = "top" var name = "top"
_, err := bt.RunTopContainer(&name, nil) _, err := bt.RunTopContainer(&name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// Check if the container is running. // Check if the container is running.
data, err := containers.Inspect(bt.conn, name, nil) data, err := containers.Inspect(bt.conn, name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(data.State.Status).To(Equal("running")) Expect(data.State.Status).To(Equal("running"))
// Prune. Should return no error no prune response ID. // Prune. Should return no error no prune response ID.
pruneResponse, err := containers.Prune(bt.conn, nil) pruneResponse, err := containers.Prune(bt.conn, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(len(pruneResponse)).To(Equal(0)) Expect(pruneResponse).To(BeEmpty())
}) })
It("podman inspect bogus container", func() { It("podman inspect bogus container", func() {
_, err := containers.Inspect(bt.conn, "foobar", nil) _, err := containers.Inspect(bt.conn, "foobar", nil)
Expect(err).ToNot(BeNil()) Expect(err).To(HaveOccurred())
code, _ := bindings.CheckResponseCode(err) code, _ := bindings.CheckResponseCode(err)
Expect(code).To(BeNumerically("==", http.StatusNotFound)) Expect(code).To(BeNumerically("==", http.StatusNotFound))
}) })
@ -635,45 +635,45 @@ var _ = Describe("Podman containers ", func() {
It("podman inspect running container", func() { It("podman inspect running container", func() {
var name = "top" var name = "top"
_, err := bt.RunTopContainer(&name, nil) _, err := bt.RunTopContainer(&name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// Inspecting running container should succeed // Inspecting running container should succeed
_, err = containers.Inspect(bt.conn, name, nil) _, err = containers.Inspect(bt.conn, name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
}) })
It("podman inspect stopped container", func() { It("podman inspect stopped container", func() {
var name = "top" var name = "top"
_, err := bt.RunTopContainer(&name, nil) _, err := bt.RunTopContainer(&name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
err = containers.Stop(bt.conn, name, nil) err = containers.Stop(bt.conn, name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// Inspecting stopped container should succeed // Inspecting stopped container should succeed
_, err = containers.Inspect(bt.conn, name, nil) _, err = containers.Inspect(bt.conn, name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
}) })
It("podman inspect running container with size", func() { It("podman inspect running container with size", func() {
var name = "top" var name = "top"
_, err := bt.RunTopContainer(&name, nil) _, err := bt.RunTopContainer(&name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
_, err = containers.Inspect(bt.conn, name, new(containers.InspectOptions).WithSize(true)) _, err = containers.Inspect(bt.conn, name, new(containers.InspectOptions).WithSize(true))
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
}) })
It("podman inspect stopped container with size", func() { It("podman inspect stopped container with size", func() {
var name = "top" var name = "top"
_, err := bt.RunTopContainer(&name, nil) _, err := bt.RunTopContainer(&name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
err = containers.Stop(bt.conn, name, nil) err = containers.Stop(bt.conn, name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// Inspecting stopped container with size should succeed // Inspecting stopped container with size should succeed
_, err = containers.Inspect(bt.conn, name, new(containers.InspectOptions).WithSize(true)) _, err = containers.Inspect(bt.conn, name, new(containers.InspectOptions).WithSize(true))
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
}) })
It("podman remove bogus container", func() { It("podman remove bogus container", func() {
_, err := containers.Remove(bt.conn, "foobar", nil) _, err := containers.Remove(bt.conn, "foobar", nil)
Expect(err).ToNot(BeNil()) Expect(err).To(HaveOccurred())
code, _ := bindings.CheckResponseCode(err) code, _ := bindings.CheckResponseCode(err)
Expect(code).To(BeNumerically("==", http.StatusNotFound)) Expect(code).To(BeNumerically("==", http.StatusNotFound))
}) })
@ -681,10 +681,10 @@ var _ = Describe("Podman containers ", func() {
It("podman remove running container by name", func() { It("podman remove running container by name", func() {
var name = "top" var name = "top"
_, err := bt.RunTopContainer(&name, nil) _, err := bt.RunTopContainer(&name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// Removing running container should fail // Removing running container should fail
_, err = containers.Remove(bt.conn, name, nil) _, err = containers.Remove(bt.conn, name, nil)
Expect(err).ToNot(BeNil()) Expect(err).To(HaveOccurred())
code, _ := bindings.CheckResponseCode(err) code, _ := bindings.CheckResponseCode(err)
Expect(code).To(BeNumerically("==", http.StatusInternalServerError)) Expect(code).To(BeNumerically("==", http.StatusInternalServerError))
}) })
@ -692,10 +692,10 @@ var _ = Describe("Podman containers ", func() {
It("podman remove running container by ID", func() { It("podman remove running container by ID", func() {
var name = "top" var name = "top"
cid, err := bt.RunTopContainer(&name, nil) cid, err := bt.RunTopContainer(&name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// Removing running container should fail // Removing running container should fail
_, err = containers.Remove(bt.conn, cid, nil) _, err = containers.Remove(bt.conn, cid, nil)
Expect(err).ToNot(BeNil()) Expect(err).To(HaveOccurred())
code, _ := bindings.CheckResponseCode(err) code, _ := bindings.CheckResponseCode(err)
Expect(code).To(BeNumerically("==", http.StatusInternalServerError)) Expect(code).To(BeNumerically("==", http.StatusInternalServerError))
}) })
@ -703,32 +703,32 @@ var _ = Describe("Podman containers ", func() {
It("podman forcibly remove running container by name", func() { It("podman forcibly remove running container by name", func() {
var name = "top" var name = "top"
_, err := bt.RunTopContainer(&name, nil) _, err := bt.RunTopContainer(&name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// Removing running container should succeed // Removing running container should succeed
rmResponse, err := containers.Remove(bt.conn, name, new(containers.RemoveOptions).WithForce(true)) rmResponse, err := containers.Remove(bt.conn, name, new(containers.RemoveOptions).WithForce(true))
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(len(reports.RmReportsErrs(rmResponse))).To(Equal(0)) Expect(reports.RmReportsErrs(rmResponse)).To(BeEmpty())
Expect(len(reports.RmReportsIds(rmResponse))).To(Equal(1)) Expect(reports.RmReportsIds(rmResponse)).To(HaveLen(1))
}) })
It("podman forcibly remove running container by ID", func() { It("podman forcibly remove running container by ID", func() {
var name = "top" var name = "top"
cid, err := bt.RunTopContainer(&name, nil) cid, err := bt.RunTopContainer(&name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// Forcibly Removing running container should succeed // Forcibly Removing running container should succeed
rmResponse, err := containers.Remove(bt.conn, cid, new(containers.RemoveOptions).WithForce(true)) rmResponse, err := containers.Remove(bt.conn, cid, new(containers.RemoveOptions).WithForce(true))
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(len(reports.RmReportsErrs(rmResponse))).To(Equal(0)) Expect(reports.RmReportsErrs(rmResponse)).To(BeEmpty())
Expect(len(reports.RmReportsIds(rmResponse))).To(Equal(1)) Expect(reports.RmReportsIds(rmResponse)).To(HaveLen(1))
}) })
It("podman remove running container and volume by name", func() { It("podman remove running container and volume by name", func() {
var name = "top" var name = "top"
_, err := bt.RunTopContainer(&name, nil) _, err := bt.RunTopContainer(&name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// Removing running container should fail // Removing running container should fail
_, err = containers.Remove(bt.conn, name, new(containers.RemoveOptions).WithVolumes(true)) _, err = containers.Remove(bt.conn, name, new(containers.RemoveOptions).WithVolumes(true))
Expect(err).ToNot(BeNil()) Expect(err).To(HaveOccurred())
code, _ := bindings.CheckResponseCode(err) code, _ := bindings.CheckResponseCode(err)
Expect(code).To(BeNumerically("==", http.StatusInternalServerError)) Expect(code).To(BeNumerically("==", http.StatusInternalServerError))
}) })
@ -736,10 +736,10 @@ var _ = Describe("Podman containers ", func() {
It("podman remove running container and volume by ID", func() { It("podman remove running container and volume by ID", func() {
var name = "top" var name = "top"
cid, err := bt.RunTopContainer(&name, nil) cid, err := bt.RunTopContainer(&name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// Removing running container should fail // Removing running container should fail
_, err = containers.Remove(bt.conn, cid, new(containers.RemoveOptions).WithVolumes(true)) _, err = containers.Remove(bt.conn, cid, new(containers.RemoveOptions).WithVolumes(true))
Expect(err).ToNot(BeNil()) Expect(err).To(HaveOccurred())
code, _ := bindings.CheckResponseCode(err) code, _ := bindings.CheckResponseCode(err)
Expect(code).To(BeNumerically("==", http.StatusInternalServerError)) Expect(code).To(BeNumerically("==", http.StatusInternalServerError))
}) })
@ -747,43 +747,43 @@ var _ = Describe("Podman containers ", func() {
It("podman forcibly remove running container and volume by name", func() { It("podman forcibly remove running container and volume by name", func() {
var name = "top" var name = "top"
_, err := bt.RunTopContainer(&name, nil) _, err := bt.RunTopContainer(&name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// Forcibly Removing running container should succeed // Forcibly Removing running container should succeed
rmResponse, err := containers.Remove(bt.conn, name, new(containers.RemoveOptions).WithVolumes(true).WithForce(true)) rmResponse, err := containers.Remove(bt.conn, name, new(containers.RemoveOptions).WithVolumes(true).WithForce(true))
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(len(reports.RmReportsErrs(rmResponse))).To(Equal(0)) Expect(reports.RmReportsErrs(rmResponse)).To(BeEmpty())
Expect(len(reports.RmReportsIds(rmResponse))).To(Equal(1)) Expect(reports.RmReportsIds(rmResponse)).To(HaveLen(1))
}) })
It("podman forcibly remove running container and volume by ID", func() { It("podman forcibly remove running container and volume by ID", func() {
var name = "top" var name = "top"
cid, err := bt.RunTopContainer(&name, nil) cid, err := bt.RunTopContainer(&name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// Removing running container should fail // Removing running container should fail
rmResponse, err := containers.Remove(bt.conn, cid, new(containers.RemoveOptions).WithForce(true).WithVolumes(true)) rmResponse, err := containers.Remove(bt.conn, cid, new(containers.RemoveOptions).WithForce(true).WithVolumes(true))
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(len(reports.RmReportsErrs(rmResponse))).To(Equal(0)) Expect(reports.RmReportsErrs(rmResponse)).To(BeEmpty())
Expect(len(reports.RmReportsIds(rmResponse))).To(Equal(1)) Expect(reports.RmReportsIds(rmResponse)).To(HaveLen(1))
}) })
It("List containers with filters", func() { It("List containers with filters", func() {
var name = "top" var name = "top"
var name2 = "top2" var name2 = "top2"
cid, err := bt.RunTopContainer(&name, nil) cid, err := bt.RunTopContainer(&name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
_, err = bt.RunTopContainer(&name2, nil) _, err = bt.RunTopContainer(&name2, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
s := specgen.NewSpecGenerator(alpine.name, false) s := specgen.NewSpecGenerator(alpine.name, false)
s.Terminal = true s.Terminal = true
s.Command = []string{"date", "-R"} s.Command = []string{"date", "-R"}
_, err = containers.CreateWithSpec(bt.conn, s, nil) _, err = containers.CreateWithSpec(bt.conn, s, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// Validate list container with id filter // Validate list container with id filter
filters := make(map[string][]string) filters := make(map[string][]string)
filters["id"] = []string{cid} filters["id"] = []string{cid}
c, err := containers.List(bt.conn, new(containers.ListOptions).WithFilters(filters).WithAll(true)) c, err := containers.List(bt.conn, new(containers.ListOptions).WithFilters(filters).WithAll(true))
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(len(c)).To(Equal(1)) Expect(c).To(HaveLen(1))
}) })
It("List containers always includes pod information", func() { It("List containers always includes pod information", func() {
@ -791,13 +791,13 @@ var _ = Describe("Podman containers ", func() {
ctrName := "testctr" ctrName := "testctr"
bt.Podcreate(&podName) bt.Podcreate(&podName)
_, err := bt.RunTopContainer(&ctrName, &podName) _, err := bt.RunTopContainer(&ctrName, &podName)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
lastNum := 1 lastNum := 1
c, err := containers.List(bt.conn, new(containers.ListOptions).WithAll(true).WithLast(lastNum)) c, err := containers.List(bt.conn, new(containers.ListOptions).WithAll(true).WithLast(lastNum))
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(len(c)).To(Equal(1)) Expect(c).To(HaveLen(1))
Expect(c[0].PodName).To(Equal(podName)) Expect(c[0].PodName).To(Equal(podName))
}) })
}) })

View File

@ -22,7 +22,7 @@ var _ = Describe("Create containers ", func() {
s = bt.startAPIService() s = bt.startAPIService()
time.Sleep(1 * time.Second) time.Sleep(1 * time.Second)
err := bt.NewConnection() err := bt.NewConnection()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
}) })
AfterEach(func() { AfterEach(func() {
@ -36,14 +36,14 @@ var _ = Describe("Create containers ", func() {
s.Terminal = true s.Terminal = true
s.Name = "top" s.Name = "top"
ctr, err := containers.CreateWithSpec(bt.conn, s, nil) ctr, err := containers.CreateWithSpec(bt.conn, s, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
data, err := containers.Inspect(bt.conn, ctr.ID, nil) data, err := containers.Inspect(bt.conn, ctr.ID, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(data.Name).To(Equal("top")) Expect(data.Name).To(Equal("top"))
err = containers.Start(bt.conn, ctr.ID, nil) err = containers.Start(bt.conn, ctr.ID, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
data, err = containers.Inspect(bt.conn, ctr.ID, nil) data, err = containers.Inspect(bt.conn, ctr.ID, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(data.State.Status).To(Equal("running")) Expect(data.State.Status).To(Equal("running"))
}) })

View File

@ -22,7 +22,7 @@ var _ = Describe("Podman containers exec", func() {
s = bt.startAPIService() s = bt.startAPIService()
time.Sleep(1 * time.Second) time.Sleep(1 * time.Second)
err := bt.NewConnection() err := bt.NewConnection()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
}) })
AfterEach(func() { AfterEach(func() {
@ -33,32 +33,32 @@ var _ = Describe("Podman containers exec", func() {
It("Podman exec create makes an exec session", func() { It("Podman exec create makes an exec session", func() {
name := "testCtr" name := "testCtr"
cid, err := bt.RunTopContainer(&name, nil) cid, err := bt.RunTopContainer(&name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
execConfig := new(handlers.ExecCreateConfig) execConfig := new(handlers.ExecCreateConfig)
execConfig.Cmd = []string{"echo", "hello world"} execConfig.Cmd = []string{"echo", "hello world"}
sessionID, err := containers.ExecCreate(bt.conn, name, execConfig) sessionID, err := containers.ExecCreate(bt.conn, name, execConfig)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(sessionID).To(Not(Equal(""))) Expect(sessionID).To(Not(Equal("")))
inspectOut, err := containers.ExecInspect(bt.conn, sessionID, nil) inspectOut, err := containers.ExecInspect(bt.conn, sessionID, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(inspectOut.ContainerID).To(Equal(cid)) Expect(inspectOut.ContainerID).To(Equal(cid))
Expect(inspectOut.ProcessConfig.Entrypoint).To(Equal("echo")) Expect(inspectOut.ProcessConfig.Entrypoint).To(Equal("echo"))
Expect(len(inspectOut.ProcessConfig.Arguments)).To(Equal(1)) Expect(inspectOut.ProcessConfig.Arguments).To(HaveLen(1))
Expect(inspectOut.ProcessConfig.Arguments[0]).To(Equal("hello world")) Expect(inspectOut.ProcessConfig.Arguments[0]).To(Equal("hello world"))
}) })
It("Podman exec create with bad command fails", func() { It("Podman exec create with bad command fails", func() {
name := "testCtr" name := "testCtr"
_, err := bt.RunTopContainer(&name, nil) _, err := bt.RunTopContainer(&name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
execConfig := new(handlers.ExecCreateConfig) execConfig := new(handlers.ExecCreateConfig)
_, err = containers.ExecCreate(bt.conn, name, execConfig) _, err = containers.ExecCreate(bt.conn, name, execConfig)
Expect(err).To(Not(BeNil())) Expect(err).To(HaveOccurred())
}) })
It("Podman exec create with invalid container fails", func() { It("Podman exec create with invalid container fails", func() {
@ -66,11 +66,11 @@ var _ = Describe("Podman containers exec", func() {
execConfig.Cmd = []string{"echo", "hello world"} execConfig.Cmd = []string{"echo", "hello world"}
_, err := containers.ExecCreate(bt.conn, "doesnotexist", execConfig) _, err := containers.ExecCreate(bt.conn, "doesnotexist", execConfig)
Expect(err).To(Not(BeNil())) Expect(err).To(HaveOccurred())
}) })
It("Podman exec inspect on invalid session fails", func() { It("Podman exec inspect on invalid session fails", func() {
_, err := containers.ExecInspect(bt.conn, "0000000000000000000000000000000000000000000000000000000000000000", nil) _, err := containers.ExecInspect(bt.conn, "0000000000000000000000000000000000000000000000000000000000000000", nil)
Expect(err).To(Not(BeNil())) Expect(err).To(HaveOccurred())
}) })
}) })

View File

@ -26,8 +26,8 @@ var _ = Describe("Podman API Bindings", func() {
})) }))
Expect(actual.GetDetachKeys()).To(Equal("Test")) Expect(actual.GetDetachKeys()).To(Equal("Test"))
Expect(actual.GetLogs()).To(Equal(true)) Expect(actual.GetLogs()).To(BeTrue())
Expect(actual.GetStream()).To(Equal(false)) Expect(actual.GetStream()).To(BeFalse())
}) })
It("verify composite setters", func() { It("verify composite setters", func() {

View File

@ -56,7 +56,7 @@ var _ = Describe("Podman images", func() {
It("inspect image", func() { It("inspect image", func() {
// Inspect invalid image be 404 // Inspect invalid image be 404
_, err = images.GetImage(bt.conn, "foobar5000", nil) _, err = images.GetImage(bt.conn, "foobar5000", nil)
Expect(err).ToNot(BeNil()) Expect(err).To(HaveOccurred())
code, _ := bindings.CheckResponseCode(err) code, _ := bindings.CheckResponseCode(err)
Expect(code).To(BeNumerically("==", http.StatusNotFound)) Expect(code).To(BeNumerically("==", http.StatusNotFound))
@ -96,14 +96,14 @@ var _ = Describe("Podman images", func() {
// images for performance reasons and for hiding the logic of // images for performance reasons and for hiding the logic of
// deciding which exit code to use from the client. // deciding which exit code to use from the client.
response, errs := images.Remove(bt.conn, []string{"foobar5000"}, nil) response, errs := images.Remove(bt.conn, []string{"foobar5000"}, nil)
Expect(len(errs)).To(BeNumerically(">", 0)) Expect(errs).ToNot(BeEmpty())
Expect(response.ExitCode).To(BeNumerically("==", 1)) // podman-remote would exit with 1 Expect(response.ExitCode).To(BeNumerically("==", 1)) // podman-remote would exit with 1
// Remove an image by name, validate image is removed and error is nil // Remove an image by name, validate image is removed and error is nil
inspectData, err := images.GetImage(bt.conn, busybox.shortName, nil) inspectData, err := images.GetImage(bt.conn, busybox.shortName, nil)
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
response, errs = images.Remove(bt.conn, []string{busybox.shortName}, nil) response, errs = images.Remove(bt.conn, []string{busybox.shortName}, nil)
Expect(len(errs)).To(BeZero()) Expect(errs).To(BeEmpty())
Expect(inspectData.ID).To(Equal(response.Deleted[0])) Expect(inspectData.ID).To(Equal(response.Deleted[0]))
_, err = images.GetImage(bt.conn, busybox.shortName, nil) _, err = images.GetImage(bt.conn, busybox.shortName, nil)
@ -150,7 +150,7 @@ var _ = Describe("Podman images", func() {
// Validates if invalid image name is given a bad response is encountered. // Validates if invalid image name is given a bad response is encountered.
err = images.Tag(bt.conn, "dummy", "demo", alpine.shortName, nil) err = images.Tag(bt.conn, "dummy", "demo", alpine.shortName, nil)
Expect(err).ToNot(BeNil()) Expect(err).To(HaveOccurred())
code, _ := bindings.CheckResponseCode(err) code, _ := bindings.CheckResponseCode(err)
Expect(code).To(BeNumerically("==", http.StatusNotFound)) Expect(code).To(BeNumerically("==", http.StatusNotFound))
@ -172,7 +172,7 @@ var _ = Describe("Podman images", func() {
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
// Since in the begin context two images are created the // Since in the begin context two images are created the
// list context should have only 2 images // list context should have only 2 images
Expect(len(imageSummary)).To(Equal(2)) Expect(imageSummary).To(HaveLen(2))
// Adding one more image. There Should be no errors in the response. // Adding one more image. There Should be no errors in the response.
// And the count should be three now. // And the count should be three now.
@ -195,13 +195,13 @@ var _ = Describe("Podman images", func() {
options := new(images.ListOptions).WithFilters(filters).WithAll(false) options := new(images.ListOptions).WithFilters(filters).WithAll(false)
filteredImages, err := images.List(bt.conn, options) filteredImages, err := images.List(bt.conn, options)
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
Expect(len(filteredImages)).To(BeNumerically("==", 1)) Expect(filteredImages).To(HaveLen(1))
// List images with a bad filter // List images with a bad filter
filters["name"] = []string{alpine.name} filters["name"] = []string{alpine.name}
options = new(images.ListOptions).WithFilters(filters) options = new(images.ListOptions).WithFilters(filters)
_, err = images.List(bt.conn, options) _, err = images.List(bt.conn, options)
Expect(err).ToNot(BeNil()) Expect(err).To(HaveOccurred())
code, _ := bindings.CheckResponseCode(err) code, _ := bindings.CheckResponseCode(err)
Expect(code).To(BeNumerically("==", http.StatusInternalServerError)) Expect(code).To(BeNumerically("==", http.StatusInternalServerError))
}) })
@ -226,7 +226,7 @@ var _ = Describe("Podman images", func() {
It("Load|Import Image", func() { It("Load|Import Image", func() {
// load an image // load an image
_, errs := images.Remove(bt.conn, []string{alpine.name}, nil) _, errs := images.Remove(bt.conn, []string{alpine.name}, nil)
Expect(len(errs)).To(BeZero()) Expect(errs).To(BeEmpty())
exists, err := images.Exists(bt.conn, alpine.name, nil) exists, err := images.Exists(bt.conn, alpine.name, nil)
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
Expect(exists).To(BeFalse()) Expect(exists).To(BeFalse())
@ -244,7 +244,7 @@ var _ = Describe("Podman images", func() {
f, err = os.Open(filepath.Join(ImageCacheDir, alpine.tarballName)) f, err = os.Open(filepath.Join(ImageCacheDir, alpine.tarballName))
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
_, errs = images.Remove(bt.conn, []string{alpine.name}, nil) _, errs = images.Remove(bt.conn, []string{alpine.name}, nil)
Expect(len(errs)).To(BeZero()) Expect(errs).To(BeEmpty())
exists, err = images.Exists(bt.conn, alpine.name, nil) exists, err = images.Exists(bt.conn, alpine.name, nil)
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
Expect(exists).To(BeFalse()) Expect(exists).To(BeFalse())
@ -254,7 +254,7 @@ var _ = Describe("Podman images", func() {
// load with a bad repo name should trigger a 500 // load with a bad repo name should trigger a 500
_, errs = images.Remove(bt.conn, []string{alpine.name}, nil) _, errs = images.Remove(bt.conn, []string{alpine.name}, nil)
Expect(len(errs)).To(BeZero()) Expect(errs).To(BeEmpty())
exists, err = images.Exists(bt.conn, alpine.name, nil) exists, err = images.Exists(bt.conn, alpine.name, nil)
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
Expect(exists).To(BeFalse()) Expect(exists).To(BeFalse())
@ -277,7 +277,7 @@ var _ = Describe("Podman images", func() {
It("Import Image", func() { It("Import Image", func() {
// load an image // load an image
_, errs := images.Remove(bt.conn, []string{alpine.name}, nil) _, errs := images.Remove(bt.conn, []string{alpine.name}, nil)
Expect(len(errs)).To(BeZero()) Expect(errs).To(BeEmpty())
exists, err := images.Exists(bt.conn, alpine.name, nil) exists, err := images.Exists(bt.conn, alpine.name, nil)
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
Expect(exists).To(BeFalse()) Expect(exists).To(BeFalse())
@ -301,7 +301,7 @@ var _ = Describe("Podman images", func() {
It("History Image", func() { It("History Image", func() {
// a bogus name should return a 404 // a bogus name should return a 404
_, err := images.History(bt.conn, "foobar", nil) _, err := images.History(bt.conn, "foobar", nil)
Expect(err).To(Not(BeNil())) Expect(err).To(HaveOccurred())
code, _ := bindings.CheckResponseCode(err) code, _ := bindings.CheckResponseCode(err)
Expect(code).To(BeNumerically("==", http.StatusNotFound)) Expect(code).To(BeNumerically("==", http.StatusNotFound))
@ -350,15 +350,15 @@ var _ = Describe("Podman images", func() {
// Search with a fqdn // Search with a fqdn
reports, err = images.Search(bt.conn, "quay.io/libpod/alpine_nginx", nil) reports, err = images.Search(bt.conn, "quay.io/libpod/alpine_nginx", nil)
Expect(err).To(BeNil(), "Error in images.Search()") Expect(err).ToNot(HaveOccurred(), "Error in images.Search()")
Expect(len(reports)).To(BeNumerically(">=", 1)) Expect(reports).ToNot(BeEmpty())
}) })
It("Prune images", func() { It("Prune images", func() {
options := new(images.PruneOptions).WithAll(true) options := new(images.PruneOptions).WithAll(true)
results, err := images.Prune(bt.conn, options) results, err := images.Prune(bt.conn, options)
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
Expect(len(results)).To(BeNumerically(">", 0)) Expect(results).ToNot(BeEmpty())
}) })
// TODO: we really need to extent to pull tests once we have a more sophisticated CI. // TODO: we really need to extent to pull tests once we have a more sophisticated CI.
@ -369,7 +369,7 @@ var _ = Describe("Podman images", func() {
pullOpts := new(images.PullOptions).WithProgressWriter(&writer) pullOpts := new(images.PullOptions).WithProgressWriter(&writer)
pulledImages, err := images.Pull(bt.conn, rawImage, pullOpts) pulledImages, err := images.Pull(bt.conn, rawImage, pullOpts)
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
Expect(len(pulledImages)).To(Equal(1)) Expect(pulledImages).To(HaveLen(1))
output := writer.String() output := writer.String()
Expect(output).To(ContainSubstring("Trying to pull ")) Expect(output).To(ContainSubstring("Trying to pull "))
Expect(output).To(ContainSubstring("Getting image source signatures")) Expect(output).To(ContainSubstring("Getting image source signatures"))
@ -389,7 +389,7 @@ var _ = Describe("Podman images", func() {
It("Image Push", func() { It("Image Push", func() {
registry, err := podmanRegistry.Start() registry, err := podmanRegistry.Start()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
var writer bytes.Buffer var writer bytes.Buffer
pushOpts := new(images.PushOptions).WithUsername(registry.User).WithPassword(registry.Password).WithSkipTLSVerify(true).WithProgressWriter(&writer).WithQuiet(false) pushOpts := new(images.PushOptions).WithUsername(registry.User).WithPassword(registry.Password).WithSkipTLSVerify(true).WithProgressWriter(&writer).WithQuiet(false)

View File

@ -25,7 +25,7 @@ var _ = Describe("Podman info", func() {
s = bt.startAPIService() s = bt.startAPIService()
time.Sleep(1 * time.Second) time.Sleep(1 * time.Second)
err := bt.NewConnection() err := bt.NewConnection()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
}) })
AfterEach(func() { AfterEach(func() {
@ -35,35 +35,35 @@ var _ = Describe("Podman info", func() {
It("podman info", func() { It("podman info", func() {
info, err := system.Info(bt.conn, nil) info, err := system.Info(bt.conn, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(info.Host.Arch).To(Equal(runtime.GOARCH)) Expect(info.Host.Arch).To(Equal(runtime.GOARCH))
Expect(info.Host.OS).To(Equal(runtime.GOOS)) Expect(info.Host.OS).To(Equal(runtime.GOOS))
listOptions := new(images.ListOptions) listOptions := new(images.ListOptions)
i, err := images.List(bt.conn, listOptions.WithAll(true)) i, err := images.List(bt.conn, listOptions.WithAll(true))
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(info.Store.ImageStore.Number).To(Equal(len(i))) Expect(info.Store.ImageStore.Number).To(Equal(len(i)))
}) })
It("podman info container counts", func() { It("podman info container counts", func() {
s := specgen.NewSpecGenerator(alpine.name, false) s := specgen.NewSpecGenerator(alpine.name, false)
_, err := containers.CreateWithSpec(bt.conn, s, nil) _, err := containers.CreateWithSpec(bt.conn, s, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
idPause, err := bt.RunTopContainer(nil, nil) idPause, err := bt.RunTopContainer(nil, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
err = containers.Pause(bt.conn, idPause, nil) err = containers.Pause(bt.conn, idPause, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
idStop, err := bt.RunTopContainer(nil, nil) idStop, err := bt.RunTopContainer(nil, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
err = containers.Stop(bt.conn, idStop, nil) err = containers.Stop(bt.conn, idStop, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
_, err = bt.RunTopContainer(nil, nil) _, err = bt.RunTopContainer(nil, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
info, err := system.Info(bt.conn, nil) info, err := system.Info(bt.conn, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(info.Store.ContainerStore.Number).To(BeNumerically("==", 4)) Expect(info.Store.ContainerStore.Number).To(BeNumerically("==", 4))
Expect(info.Store.ContainerStore.Paused).To(Equal(1)) Expect(info.Store.ContainerStore.Paused).To(Equal(1))

View File

@ -43,7 +43,7 @@ var _ = Describe("Podman manifests", func() {
list, err := manifests.Inspect(bt.conn, id, nil) list, err := manifests.Inspect(bt.conn, id, nil)
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
Expect(len(list.Manifests)).To(BeZero()) Expect(list.Manifests).To(BeEmpty())
// creating a duplicate should fail as a 500 // creating a duplicate should fail as a 500
_, err = manifests.Create(bt.conn, "quay.io/libpod/foobar:latest", nil, nil) _, err = manifests.Create(bt.conn, "quay.io/libpod/foobar:latest", nil, nil)
@ -53,7 +53,7 @@ var _ = Describe("Podman manifests", func() {
Expect(code).To(BeNumerically("==", http.StatusInternalServerError)) Expect(code).To(BeNumerically("==", http.StatusInternalServerError))
_, errs := images.Remove(bt.conn, []string{id}, nil) _, errs := images.Remove(bt.conn, []string{id}, nil)
Expect(len(errs)).To(BeZero()) Expect(errs).To(BeEmpty())
// create manifest list with images // create manifest list with images
id, err = manifests.Create(bt.conn, "quay.io/libpod/foobar:latest", []string{alpine.name}, nil) id, err = manifests.Create(bt.conn, "quay.io/libpod/foobar:latest", []string{alpine.name}, nil)
@ -62,7 +62,7 @@ var _ = Describe("Podman manifests", func() {
list, err = manifests.Inspect(bt.conn, id, nil) list, err = manifests.Inspect(bt.conn, id, nil)
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
Expect(len(list.Manifests)).To(BeNumerically("==", 1)) Expect(list.Manifests).To(HaveLen(1))
}) })
It("delete manifest", func() { It("delete manifest", func() {
@ -71,11 +71,11 @@ var _ = Describe("Podman manifests", func() {
list, err := manifests.Inspect(bt.conn, id, nil) list, err := manifests.Inspect(bt.conn, id, nil)
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
Expect(len(list.Manifests)).To(BeZero()) Expect(list.Manifests).To(BeEmpty())
removeReport, err := manifests.Delete(bt.conn, "quay.io/libpod/foobar:latest") removeReport, err := manifests.Delete(bt.conn, "quay.io/libpod/foobar:latest")
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
Expect(len(removeReport.Deleted)).To(BeNumerically("==", 1)) Expect(removeReport.Deleted).To(HaveLen(1))
}) })
It("inspect", func() { It("inspect", func() {
@ -104,7 +104,7 @@ var _ = Describe("Podman manifests", func() {
list, err := manifests.Inspect(bt.conn, id, nil) list, err := manifests.Inspect(bt.conn, id, nil)
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
Expect(len(list.Manifests)).To(BeNumerically("==", 1)) Expect(list.Manifests).To(HaveLen(1))
// add bogus name to existing list should fail // add bogus name to existing list should fail
options.WithImages([]string{"larry"}) options.WithImages([]string{"larry"})
@ -129,7 +129,7 @@ var _ = Describe("Podman manifests", func() {
data, err := manifests.Inspect(bt.conn, id, nil) data, err := manifests.Inspect(bt.conn, id, nil)
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
Expect(len(data.Manifests)).To(BeNumerically("==", 1)) Expect(data.Manifests).To(HaveLen(1))
// removal on a good manifest list with a bad digest should be 400 // removal on a good manifest list with a bad digest should be 400
_, err = manifests.Remove(bt.conn, id, "!234", nil) _, err = manifests.Remove(bt.conn, id, "!234", nil)
@ -161,7 +161,7 @@ var _ = Describe("Podman manifests", func() {
data, err := manifests.Inspect(bt.conn, id, nil) data, err := manifests.Inspect(bt.conn, id, nil)
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
Expect(len(data.Manifests)).To(BeNumerically("==", 1)) Expect(data.Manifests).To(HaveLen(1))
digest := data.Manifests[0].Digest.String() digest := data.Manifests[0].Digest.String()
annoOpts := new(manifests.ModifyOptions).WithOS("foo") annoOpts := new(manifests.ModifyOptions).WithOS("foo")
@ -171,13 +171,13 @@ var _ = Describe("Podman manifests", func() {
list, err := manifests.Inspect(bt.conn, id, nil) list, err := manifests.Inspect(bt.conn, id, nil)
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
Expect(len(list.Manifests)).To(BeNumerically("==", 1)) Expect(list.Manifests).To(HaveLen(1))
Expect(list.Manifests[0].Platform.OS).To(Equal("foo")) Expect(list.Manifests[0].Platform.OS).To(Equal("foo"))
}) })
It("Manifest Push", func() { It("Manifest Push", func() {
registry, err := podmanRegistry.Start() registry, err := podmanRegistry.Start()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
name := "quay.io/libpod/foobar:latest" name := "quay.io/libpod/foobar:latest"
_, err = manifests.Create(bt.conn, name, []string{alpine.name}, nil) _, err = manifests.Create(bt.conn, name, []string{alpine.name}, nil)

View File

@ -30,9 +30,9 @@ var _ = Describe("Podman networks", func() {
s = bt.startAPIService() s = bt.startAPIService()
time.Sleep(1 * time.Second) time.Sleep(1 * time.Second)
connText, err = bindings.NewConnection(context.Background(), bt.sock) connText, err = bindings.NewConnection(context.Background(), bt.sock)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
_, err = network.Prune(connText, &network.PruneOptions{}) _, err = network.Prune(connText, &network.PruneOptions{})
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
}) })
AfterEach(func() { AfterEach(func() {
@ -46,51 +46,51 @@ var _ = Describe("Podman networks", func() {
Name: name, Name: name,
} }
_, err = network.Create(connText, &net) _, err = network.Create(connText, &net)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// Invalid filters should return error // Invalid filters should return error
filtersIncorrect := map[string][]string{ filtersIncorrect := map[string][]string{
"status": {"dummy"}, "status": {"dummy"},
} }
_, err = network.Prune(connText, new(network.PruneOptions).WithFilters(filtersIncorrect)) _, err = network.Prune(connText, new(network.PruneOptions).WithFilters(filtersIncorrect))
Expect(err).ToNot(BeNil()) Expect(err).To(HaveOccurred())
// List filter params should not work with prune. // List filter params should not work with prune.
filtersIncorrect = map[string][]string{ filtersIncorrect = map[string][]string{
"name": {name}, "name": {name},
} }
_, err = network.Prune(connText, new(network.PruneOptions).WithFilters(filtersIncorrect)) _, err = network.Prune(connText, new(network.PruneOptions).WithFilters(filtersIncorrect))
Expect(err).ToNot(BeNil()) Expect(err).To(HaveOccurred())
// Mismatched label, correct filter params => no network should be pruned. // Mismatched label, correct filter params => no network should be pruned.
filtersIncorrect = map[string][]string{ filtersIncorrect = map[string][]string{
"label": {"xyz"}, "label": {"xyz"},
} }
pruneResponse, err := network.Prune(connText, new(network.PruneOptions).WithFilters(filtersIncorrect)) pruneResponse, err := network.Prune(connText, new(network.PruneOptions).WithFilters(filtersIncorrect))
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(len(pruneResponse)).To(Equal(0)) Expect(pruneResponse).To(BeEmpty())
// Mismatched until, correct filter params => no network should be pruned. // Mismatched until, correct filter params => no network should be pruned.
filters := map[string][]string{ filters := map[string][]string{
"until": {"50"}, // January 1, 1970 "until": {"50"}, // January 1, 1970
} }
pruneResponse, err = network.Prune(connText, new(network.PruneOptions).WithFilters(filters)) pruneResponse, err = network.Prune(connText, new(network.PruneOptions).WithFilters(filters))
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(len(pruneResponse)).To(Equal(0)) Expect(pruneResponse).To(BeEmpty())
// Valid filter params => network should be pruned now. // Valid filter params => network should be pruned now.
filters = map[string][]string{ filters = map[string][]string{
"until": {"5000000000"}, // June 11, 2128 "until": {"5000000000"}, // June 11, 2128
} }
pruneResponse, err = network.Prune(connText, new(network.PruneOptions).WithFilters(filters)) pruneResponse, err = network.Prune(connText, new(network.PruneOptions).WithFilters(filters))
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(len(pruneResponse)).To(Equal(1)) Expect(pruneResponse).To(HaveLen(1))
}) })
It("create network", func() { It("create network", func() {
// create a network with blank config should work // create a network with blank config should work
_, err = network.Create(connText, nil) _, err = network.Create(connText, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
name := "foobar" name := "foobar"
net := types.Network{ net := types.Network{
@ -98,12 +98,12 @@ var _ = Describe("Podman networks", func() {
} }
report, err := network.Create(connText, &net) report, err := network.Create(connText, &net)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(report.Name).To(Equal(name)) Expect(report.Name).To(Equal(name))
// create network with same name should 500 // create network with same name should 500
_, err = network.Create(connText, &net) _, err = network.Create(connText, &net)
Expect(err).ToNot(BeNil()) Expect(err).To(HaveOccurred())
code, _ := bindings.CheckResponseCode(err) code, _ := bindings.CheckResponseCode(err)
Expect(code).To(BeNumerically("==", http.StatusConflict)) Expect(code).To(BeNumerically("==", http.StatusConflict))
}) })
@ -114,9 +114,9 @@ var _ = Describe("Podman networks", func() {
Name: name, Name: name,
} }
_, err = network.Create(connText, &net) _, err = network.Create(connText, &net)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
data, err := network.Inspect(connText, name, nil) data, err := network.Inspect(connText, name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(data.Name).To(Equal(name)) Expect(data.Name).To(Equal(name))
}) })
@ -128,10 +128,10 @@ var _ = Describe("Podman networks", func() {
Name: netNames[i], Name: netNames[i],
} }
_, err = network.Create(connText, &net) _, err = network.Create(connText, &net)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
} }
list, err := network.List(connText, nil) list, err := network.List(connText, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(len(list)).To(BeNumerically(">=", 5)) Expect(len(list)).To(BeNumerically(">=", 5))
for _, n := range list { for _, n := range list {
if n.Name != "podman" { if n.Name != "podman" {
@ -144,7 +144,7 @@ var _ = Describe("Podman networks", func() {
filters["foobar"] = []string{"1234"} filters["foobar"] = []string{"1234"}
options := new(network.ListOptions).WithFilters(filters) options := new(network.ListOptions).WithFilters(filters)
_, err = network.List(connText, options) _, err = network.List(connText, options)
Expect(err).ToNot(BeNil()) Expect(err).To(HaveOccurred())
code, _ := bindings.CheckResponseCode(err) code, _ := bindings.CheckResponseCode(err)
Expect(code).To(BeNumerically("==", http.StatusInternalServerError)) Expect(code).To(BeNumerically("==", http.StatusInternalServerError))
@ -153,8 +153,8 @@ var _ = Describe("Podman networks", func() {
filters["name"] = []string{"homer"} filters["name"] = []string{"homer"}
options = new(network.ListOptions).WithFilters(filters) options = new(network.ListOptions).WithFilters(filters)
list, err = network.List(connText, options) list, err = network.List(connText, options)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(len(list)).To(BeNumerically("==", 1)) Expect(list).To(HaveLen(1))
Expect(list[0].Name).To(Equal("homer")) Expect(list[0].Name).To(Equal("homer"))
}) })
@ -162,7 +162,7 @@ var _ = Describe("Podman networks", func() {
// removing a noName network should result in 404 // removing a noName network should result in 404
_, err := network.Remove(connText, "noName", nil) _, err := network.Remove(connText, "noName", nil)
code, err := bindings.CheckResponseCode(err) code, err := bindings.CheckResponseCode(err)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(code).To(BeNumerically("==", http.StatusNotFound)) Expect(code).To(BeNumerically("==", http.StatusNotFound))
// Removing an unused network should work // Removing an unused network should work
@ -171,9 +171,9 @@ var _ = Describe("Podman networks", func() {
Name: name, Name: name,
} }
_, err = network.Create(connText, &net) _, err = network.Create(connText, &net)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
report, err := network.Remove(connText, name, nil) report, err := network.Remove(connText, name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(report[0].Name).To(Equal(name)) Expect(report[0].Name).To(Equal(name))
// Removing a network that is being used without force should be 500 // Removing a network that is being used without force should be 500
@ -182,7 +182,7 @@ var _ = Describe("Podman networks", func() {
Name: name, Name: name,
} }
_, err = network.Create(connText, &net) _, err = network.Create(connText, &net)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// Start container and wait // Start container and wait
container := "ntest" container := "ntest"
@ -192,15 +192,15 @@ var _ = Describe("Podman networks", func() {
_, err = network.Remove(connText, name, nil) _, err = network.Remove(connText, name, nil)
code, err = bindings.CheckResponseCode(err) code, err = bindings.CheckResponseCode(err)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(code).To(BeNumerically("==", http.StatusInternalServerError)) Expect(code).To(BeNumerically("==", http.StatusInternalServerError))
// Removing with a network in use with force should work with a stopped container // Removing with a network in use with force should work with a stopped container
err = containers.Stop(connText, container, new(containers.StopOptions).WithTimeout(0)) err = containers.Stop(connText, container, new(containers.StopOptions).WithTimeout(0))
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
options := new(network.RemoveOptions).WithForce(true) options := new(network.RemoveOptions).WithForce(true)
report, err = network.Remove(connText, name, options) report, err = network.Remove(connText, name, options)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(report[0].Name).To(Equal(name)) Expect(report[0].Name).To(Equal(name))
}) })
}) })

View File

@ -34,7 +34,7 @@ var _ = Describe("Podman pods", func() {
s = bt.startAPIService() s = bt.startAPIService()
time.Sleep(1 * time.Second) time.Sleep(1 * time.Second)
err := bt.NewConnection() err := bt.NewConnection()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
}) })
AfterEach(func() { AfterEach(func() {
@ -45,13 +45,13 @@ var _ = Describe("Podman pods", func() {
It("inspect pod", func() { It("inspect pod", func() {
// Inspect an invalid pod name // Inspect an invalid pod name
_, err := pods.Inspect(bt.conn, "dummyname", nil) _, err := pods.Inspect(bt.conn, "dummyname", nil)
Expect(err).ToNot(BeNil()) Expect(err).To(HaveOccurred())
code, _ := bindings.CheckResponseCode(err) code, _ := bindings.CheckResponseCode(err)
Expect(code).To(BeNumerically("==", http.StatusNotFound)) Expect(code).To(BeNumerically("==", http.StatusNotFound))
// Inspect an valid pod name // Inspect an valid pod name
response, err := pods.Inspect(bt.conn, newpod, nil) response, err := pods.Inspect(bt.conn, newpod, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(response.Name).To(Equal(newpod)) Expect(response.Name).To(Equal(newpod))
}) })
@ -59,28 +59,28 @@ var _ = Describe("Podman pods", func() {
It("list pod", func() { It("list pod", func() {
// List all the pods in the current instance // List all the pods in the current instance
podSummary, err := pods.List(bt.conn, nil) podSummary, err := pods.List(bt.conn, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(len(podSummary)).To(Equal(1)) Expect(podSummary).To(HaveLen(1))
// Start the pod // Start the pod
_, err = pods.Start(bt.conn, newpod, nil) _, err = pods.Start(bt.conn, newpod, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// Adding an alpine container to the existing pod // Adding an alpine container to the existing pod
_, err = bt.RunTopContainer(nil, &newpod) _, err = bt.RunTopContainer(nil, &newpod)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
podSummary, err = pods.List(bt.conn, nil) podSummary, err = pods.List(bt.conn, nil)
// Verify no errors. // Verify no errors.
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// Verify number of containers in the pod. // Verify number of containers in the pod.
Expect(len(podSummary[0].Containers)).To(Equal(2)) Expect(podSummary[0].Containers).To(HaveLen(2))
// Add multiple pods and verify them by name and size. // Add multiple pods and verify them by name and size.
var newpod2 string = "newpod2" var newpod2 string = "newpod2"
bt.Podcreate(&newpod2) bt.Podcreate(&newpod2)
podSummary, err = pods.List(bt.conn, nil) podSummary, err = pods.List(bt.conn, nil)
Expect(err).To(BeNil(), "Error from pods.List") Expect(err).ToNot(HaveOccurred(), "Error from pods.List")
Expect(len(podSummary)).To(Equal(2)) Expect(podSummary).To(HaveLen(2))
var names []string var names []string
for _, i := range podSummary { for _, i := range podSummary {
names = append(names, i.Name) names = append(names, i.Name)
@ -96,18 +96,18 @@ var _ = Describe("Podman pods", func() {
// Start the pod // Start the pod
_, err = pods.Start(bt.conn, newpod, nil) _, err = pods.Start(bt.conn, newpod, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
_, err = bt.RunTopContainer(nil, &newpod) _, err = bt.RunTopContainer(nil, &newpod)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// Expected err with invalid filter params // Expected err with invalid filter params
filters := make(map[string][]string) filters := make(map[string][]string)
filters["dummy"] = []string{"dummy"} filters["dummy"] = []string{"dummy"}
options := new(pods.ListOptions).WithFilters(filters) options := new(pods.ListOptions).WithFilters(filters)
filteredPods, err := pods.List(bt.conn, options) filteredPods, err := pods.List(bt.conn, options)
Expect(err).ToNot(BeNil()) Expect(err).To(HaveOccurred())
Expect(len(filteredPods)).To(Equal(0), "len(filteredPods)") Expect(filteredPods).To(BeEmpty(), "len(filteredPods)")
code, _ := bindings.CheckResponseCode(err) code, _ := bindings.CheckResponseCode(err)
Expect(code).To(BeNumerically("==", http.StatusInternalServerError)) Expect(code).To(BeNumerically("==", http.StatusInternalServerError))
@ -116,16 +116,16 @@ var _ = Describe("Podman pods", func() {
filters["name"] = []string{"dummy"} filters["name"] = []string{"dummy"}
options = new(pods.ListOptions).WithFilters(filters) options = new(pods.ListOptions).WithFilters(filters)
filteredPods, err = pods.List(bt.conn, options) filteredPods, err = pods.List(bt.conn, options)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(len(filteredPods)).To(BeNumerically("==", 0)) Expect(filteredPods).To(BeEmpty())
// Validate list pod with name filter // Validate list pod with name filter
filters = make(map[string][]string) filters = make(map[string][]string)
filters["name"] = []string{newpod2} filters["name"] = []string{newpod2}
options = new(pods.ListOptions).WithFilters(filters) options = new(pods.ListOptions).WithFilters(filters)
filteredPods, err = pods.List(bt.conn, options) filteredPods, err = pods.List(bt.conn, options)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(len(filteredPods)).To(BeNumerically("==", 1)) Expect(filteredPods).To(HaveLen(1))
var names []string var names []string
for _, i := range filteredPods { for _, i := range filteredPods {
names = append(names, i.Name) names = append(names, i.Name)
@ -135,13 +135,13 @@ var _ = Describe("Podman pods", func() {
// Validate list pod with id filter // Validate list pod with id filter
filters = make(map[string][]string) filters = make(map[string][]string)
response, err := pods.Inspect(bt.conn, newpod, nil) response, err := pods.Inspect(bt.conn, newpod, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
id := response.ID id := response.ID
filters["id"] = []string{id} filters["id"] = []string{id}
options = new(pods.ListOptions).WithFilters(filters) options = new(pods.ListOptions).WithFilters(filters)
filteredPods, err = pods.List(bt.conn, options) filteredPods, err = pods.List(bt.conn, options)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(len(filteredPods)).To(BeNumerically("==", 1)) Expect(filteredPods).To(HaveLen(1))
names = names[:0] names = names[:0]
for _, i := range filteredPods { for _, i := range filteredPods {
names = append(names, i.Name) names = append(names, i.Name)
@ -152,8 +152,8 @@ var _ = Describe("Podman pods", func() {
filters["name"] = []string{newpod} filters["name"] = []string{newpod}
options = new(pods.ListOptions).WithFilters(filters) options = new(pods.ListOptions).WithFilters(filters)
filteredPods, err = pods.List(bt.conn, options) filteredPods, err = pods.List(bt.conn, options)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(len(filteredPods)).To(BeNumerically("==", 1)) Expect(filteredPods).To(HaveLen(1))
names = names[:0] names = names[:0]
for _, i := range filteredPods { for _, i := range filteredPods {
names = append(names, i.Name) names = append(names, i.Name)
@ -164,12 +164,12 @@ var _ = Describe("Podman pods", func() {
// The test validates if the exists responds // The test validates if the exists responds
It("exists pod", func() { It("exists pod", func() {
response, err := pods.Exists(bt.conn, "dummyName", nil) response, err := pods.Exists(bt.conn, "dummyName", nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(response).To(BeFalse()) Expect(response).To(BeFalse())
// Should exit with no error and response should be true // Should exit with no error and response should be true
response, err = pods.Exists(bt.conn, "newpod", nil) response, err = pods.Exists(bt.conn, "newpod", nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(response).To(BeTrue()) Expect(response).To(BeTrue())
}) })
@ -180,21 +180,21 @@ var _ = Describe("Podman pods", func() {
Skip("Pod behavior is jacked right now.") Skip("Pod behavior is jacked right now.")
// Pause invalid container // Pause invalid container
_, err := pods.Pause(bt.conn, "dummyName", nil) _, err := pods.Pause(bt.conn, "dummyName", nil)
Expect(err).ToNot(BeNil()) Expect(err).To(HaveOccurred())
code, _ := bindings.CheckResponseCode(err) code, _ := bindings.CheckResponseCode(err)
Expect(code).To(BeNumerically("==", http.StatusNotFound)) Expect(code).To(BeNumerically("==", http.StatusNotFound))
// Adding an alpine container to the existing pod // Adding an alpine container to the existing pod
_, err = bt.RunTopContainer(nil, &newpod) _, err = bt.RunTopContainer(nil, &newpod)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// Binding needs to be modified to inspect the pod state. // Binding needs to be modified to inspect the pod state.
// Since we don't have a pod state we inspect the states of the containers within the pod. // Since we don't have a pod state we inspect the states of the containers within the pod.
// Pause a valid container // Pause a valid container
_, err = pods.Pause(bt.conn, newpod, nil) _, err = pods.Pause(bt.conn, newpod, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
response, err := pods.Inspect(bt.conn, newpod, nil) response, err := pods.Inspect(bt.conn, newpod, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(response.State).To(Equal(define.PodStatePaused)) Expect(response.State).To(Equal(define.PodStatePaused))
for _, i := range response.Containers { for _, i := range response.Containers {
Expect(define.StringToContainerStatus(i.State)). Expect(define.StringToContainerStatus(i.State)).
@ -203,9 +203,9 @@ var _ = Describe("Podman pods", func() {
// Unpause a valid container // Unpause a valid container
_, err = pods.Unpause(bt.conn, newpod, nil) _, err = pods.Unpause(bt.conn, newpod, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
response, err = pods.Inspect(bt.conn, newpod, nil) response, err = pods.Inspect(bt.conn, newpod, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(response.State).To(Equal(define.PodStateRunning)) Expect(response.State).To(Equal(define.PodStateRunning))
for _, i := range response.Containers { for _, i := range response.Containers {
Expect(define.StringToContainerStatus(i.State)). Expect(define.StringToContainerStatus(i.State)).
@ -215,7 +215,7 @@ var _ = Describe("Podman pods", func() {
It("start pod with port conflict", func() { It("start pod with port conflict", func() {
randomport, err := utils.GetRandomPort() randomport, err := utils.GetRandomPort()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
portPublish := fmt.Sprintf("%d:%d", randomport, randomport) portPublish := fmt.Sprintf("%d:%d", randomport, randomport)
var podwithport string = "newpodwithport" var podwithport string = "newpodwithport"
@ -223,14 +223,14 @@ var _ = Describe("Podman pods", func() {
// Start pod and expose port 12345 // Start pod and expose port 12345
_, err = pods.Start(bt.conn, podwithport, nil) _, err = pods.Start(bt.conn, podwithport, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// Start another pod and expose same port 12345 // Start another pod and expose same port 12345
var podwithport2 string = "newpodwithport2" var podwithport2 string = "newpodwithport2"
bt.PodcreateAndExpose(&podwithport2, &portPublish) bt.PodcreateAndExpose(&podwithport2, &portPublish)
_, err = pods.Start(bt.conn, podwithport2, nil) _, err = pods.Start(bt.conn, podwithport2, nil)
Expect(err).ToNot(BeNil()) Expect(err).To(HaveOccurred())
code, _ := bindings.CheckResponseCode(err) code, _ := bindings.CheckResponseCode(err)
Expect(code).To(BeNumerically("==", http.StatusConflict)) Expect(code).To(BeNumerically("==", http.StatusConflict))
Expect(err).To(BeAssignableToTypeOf(&errorhandling.PodConflictErrorModel{})) Expect(err).To(BeAssignableToTypeOf(&errorhandling.PodConflictErrorModel{}))
@ -239,28 +239,28 @@ var _ = Describe("Podman pods", func() {
It("start stop restart pod", func() { It("start stop restart pod", func() {
// Start an invalid pod // Start an invalid pod
_, err = pods.Start(bt.conn, "dummyName", nil) _, err = pods.Start(bt.conn, "dummyName", nil)
Expect(err).ToNot(BeNil()) Expect(err).To(HaveOccurred())
code, _ := bindings.CheckResponseCode(err) code, _ := bindings.CheckResponseCode(err)
Expect(code).To(BeNumerically("==", http.StatusNotFound)) Expect(code).To(BeNumerically("==", http.StatusNotFound))
// Stop an invalid pod // Stop an invalid pod
_, err = pods.Stop(bt.conn, "dummyName", nil) _, err = pods.Stop(bt.conn, "dummyName", nil)
Expect(err).ToNot(BeNil()) Expect(err).To(HaveOccurred())
code, _ = bindings.CheckResponseCode(err) code, _ = bindings.CheckResponseCode(err)
Expect(code).To(BeNumerically("==", http.StatusNotFound)) Expect(code).To(BeNumerically("==", http.StatusNotFound))
// Restart an invalid pod // Restart an invalid pod
_, err = pods.Restart(bt.conn, "dummyName", nil) _, err = pods.Restart(bt.conn, "dummyName", nil)
Expect(err).ToNot(BeNil()) Expect(err).To(HaveOccurred())
code, _ = bindings.CheckResponseCode(err) code, _ = bindings.CheckResponseCode(err)
Expect(code).To(BeNumerically("==", http.StatusNotFound)) Expect(code).To(BeNumerically("==", http.StatusNotFound))
// Start a valid pod and inspect status of each container // Start a valid pod and inspect status of each container
_, err = pods.Start(bt.conn, newpod, nil) _, err = pods.Start(bt.conn, newpod, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
response, err := pods.Inspect(bt.conn, newpod, nil) response, err := pods.Inspect(bt.conn, newpod, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(response.State).To(Equal(define.PodStateRunning)) Expect(response.State).To(Equal(define.PodStateRunning))
for _, i := range response.Containers { for _, i := range response.Containers {
Expect(define.StringToContainerStatus(i.State)). Expect(define.StringToContainerStatus(i.State)).
@ -269,11 +269,11 @@ var _ = Describe("Podman pods", func() {
// Start an already running pod // Start an already running pod
_, err = pods.Start(bt.conn, newpod, nil) _, err = pods.Start(bt.conn, newpod, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// Stop the running pods // Stop the running pods
_, err = pods.Stop(bt.conn, newpod, nil) _, err = pods.Stop(bt.conn, newpod, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
response, _ = pods.Inspect(bt.conn, newpod, nil) response, _ = pods.Inspect(bt.conn, newpod, nil)
Expect(response.State).To(Equal(define.PodStateExited)) Expect(response.State).To(Equal(define.PodStateExited))
for _, i := range response.Containers { for _, i := range response.Containers {
@ -283,10 +283,10 @@ var _ = Describe("Podman pods", func() {
// Stop an already stopped pod // Stop an already stopped pod
_, err = pods.Stop(bt.conn, newpod, nil) _, err = pods.Stop(bt.conn, newpod, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
_, err = pods.Restart(bt.conn, newpod, nil) _, err = pods.Restart(bt.conn, newpod, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
response, _ = pods.Inspect(bt.conn, newpod, nil) response, _ = pods.Inspect(bt.conn, newpod, nil)
Expect(response.State).To(Equal(define.PodStateRunning)) Expect(response.State).To(Equal(define.PodStateRunning))
for _, i := range response.Containers { for _, i := range response.Containers {
@ -302,75 +302,75 @@ var _ = Describe("Podman pods", func() {
bt.Podcreate(&newpod2) bt.Podcreate(&newpod2)
// No pods pruned since no pod in exited state // No pods pruned since no pod in exited state
pruneResponse, err := pods.Prune(bt.conn, nil) pruneResponse, err := pods.Prune(bt.conn, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(len(pruneResponse)).To(Equal(0), "len(pruneResponse)") Expect(pruneResponse).To(BeEmpty(), "len(pruneResponse)")
podSummary, err := pods.List(bt.conn, nil) podSummary, err := pods.List(bt.conn, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(len(podSummary)).To(Equal(2)) Expect(podSummary).To(HaveLen(2))
// Prune only one pod which is in exited state. // Prune only one pod which is in exited state.
// Start then stop a pod. // Start then stop a pod.
// pod moves to exited state one pod should be pruned now. // pod moves to exited state one pod should be pruned now.
_, err = pods.Start(bt.conn, newpod, nil) _, err = pods.Start(bt.conn, newpod, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
_, err = pods.Stop(bt.conn, newpod, nil) _, err = pods.Stop(bt.conn, newpod, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
response, err := pods.Inspect(bt.conn, newpod, nil) response, err := pods.Inspect(bt.conn, newpod, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(response.State).To(Equal(define.PodStateExited)) Expect(response.State).To(Equal(define.PodStateExited))
pruneResponse, err = pods.Prune(bt.conn, nil) pruneResponse, err = pods.Prune(bt.conn, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(len(pruneResponse)).To(Equal(1), "len(pruneResponse)") Expect(pruneResponse).To(HaveLen(1), "len(pruneResponse)")
// Validate status and record pod id of pod to be pruned // Validate status and record pod id of pod to be pruned
Expect(response.State).To(Equal(define.PodStateExited)) Expect(response.State).To(Equal(define.PodStateExited))
podID := response.ID podID := response.ID
// Check if right pod was pruned // Check if right pod was pruned
Expect(len(pruneResponse)).To(Equal(1)) Expect(pruneResponse).To(HaveLen(1))
Expect(pruneResponse[0].Id).To(Equal(podID)) Expect(pruneResponse[0].Id).To(Equal(podID))
// One pod is pruned hence only one pod should be active. // One pod is pruned hence only one pod should be active.
podSummary, err = pods.List(bt.conn, nil) podSummary, err = pods.List(bt.conn, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(len(podSummary)).To(Equal(1)) Expect(podSummary).To(HaveLen(1))
// Test prune multiple pods. // Test prune multiple pods.
bt.Podcreate(&newpod) bt.Podcreate(&newpod)
_, err = pods.Start(bt.conn, newpod, nil) _, err = pods.Start(bt.conn, newpod, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
_, err = pods.Start(bt.conn, newpod2, nil) _, err = pods.Start(bt.conn, newpod2, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
_, err = pods.Stop(bt.conn, newpod, nil) _, err = pods.Stop(bt.conn, newpod, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
response, err = pods.Inspect(bt.conn, newpod, nil) response, err = pods.Inspect(bt.conn, newpod, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(response.State).To(Equal(define.PodStateExited)) Expect(response.State).To(Equal(define.PodStateExited))
for _, i := range response.Containers { for _, i := range response.Containers {
Expect(define.StringToContainerStatus(i.State)). Expect(define.StringToContainerStatus(i.State)).
To(Equal(define.ContainerStateExited)) To(Equal(define.ContainerStateExited))
} }
_, err = pods.Stop(bt.conn, newpod2, nil) _, err = pods.Stop(bt.conn, newpod2, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
response, err = pods.Inspect(bt.conn, newpod2, nil) response, err = pods.Inspect(bt.conn, newpod2, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(response.State).To(Equal(define.PodStateExited)) Expect(response.State).To(Equal(define.PodStateExited))
for _, i := range response.Containers { for _, i := range response.Containers {
Expect(define.StringToContainerStatus(i.State)). Expect(define.StringToContainerStatus(i.State)).
To(Equal(define.ContainerStateExited)) To(Equal(define.ContainerStateExited))
} }
_, err = pods.Prune(bt.conn, nil) _, err = pods.Prune(bt.conn, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
podSummary, err = pods.List(bt.conn, nil) podSummary, err = pods.List(bt.conn, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(len(podSummary)).To(Equal(0)) Expect(podSummary).To(BeEmpty())
}) })
It("simple create pod", func() { It("simple create pod", func() {
ps := entities.PodSpec{PodSpecGen: specgen.PodSpecGenerator{InfraContainerSpec: &specgen.SpecGenerator{}}} ps := entities.PodSpec{PodSpecGen: specgen.PodSpecGenerator{InfraContainerSpec: &specgen.SpecGenerator{}}}
ps.PodSpecGen.Name = "foobar" ps.PodSpecGen.Name = "foobar"
_, err := pods.CreatePodFromSpec(bt.conn, &ps) _, err := pods.CreatePodFromSpec(bt.conn, &ps)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
exists, err := pods.Exists(bt.conn, "foobar", nil) exists, err := pods.Exists(bt.conn, "foobar", nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(exists).To(BeTrue()) Expect(exists).To(BeTrue())
}) })
@ -380,16 +380,16 @@ var _ = Describe("Podman pods", func() {
bt.Podcreate(&name) bt.Podcreate(&name)
_, err := pods.Start(bt.conn, name, nil) _, err := pods.Start(bt.conn, name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// By name // By name
_, err = pods.Top(bt.conn, name, nil) _, err = pods.Top(bt.conn, name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// With descriptors // With descriptors
options := new(pods.TopOptions).WithDescriptors([]string{"user,pid,hpid"}) options := new(pods.TopOptions).WithDescriptors([]string{"user,pid,hpid"})
output, err := pods.Top(bt.conn, name, options) output, err := pods.Top(bt.conn, name, options)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
header := strings.Split(output[0], "\t") header := strings.Split(output[0], "\t")
for _, d := range []string{"USER", "PID", "HPID"} { for _, d := range []string{"USER", "PID", "HPID"} {
Expect(d).To(BeElementOf(header)) Expect(d).To(BeElementOf(header))
@ -397,11 +397,11 @@ var _ = Describe("Podman pods", func() {
// With bogus ID // With bogus ID
_, err = pods.Top(bt.conn, "IdoNotExist", nil) _, err = pods.Top(bt.conn, "IdoNotExist", nil)
Expect(err).ToNot(BeNil()) Expect(err).To(HaveOccurred())
// With bogus descriptors // With bogus descriptors
options = new(pods.TopOptions).WithDescriptors([]string{"Me,Neither"}) options = new(pods.TopOptions).WithDescriptors([]string{"Me,Neither"})
_, err = pods.Top(bt.conn, name, options) _, err = pods.Top(bt.conn, name, options)
Expect(err).ToNot(BeNil()) Expect(err).To(HaveOccurred())
}) })
}) })

View File

@ -27,7 +27,7 @@ var _ = Describe("Podman secrets", func() {
s = bt.startAPIService() s = bt.startAPIService()
time.Sleep(1 * time.Second) time.Sleep(1 * time.Second)
connText, err = bindings.NewConnection(context.Background(), bt.sock) connText, err = bindings.NewConnection(context.Background(), bt.sock)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
}) })
AfterEach(func() { AfterEach(func() {
@ -43,11 +43,11 @@ var _ = Describe("Podman secrets", func() {
Name: &name, Name: &name,
} }
_, err := secrets.Create(connText, r, opts) _, err := secrets.Create(connText, r, opts)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// should not be allowed to create duplicate secret name // should not be allowed to create duplicate secret name
_, err = secrets.Create(connText, r, opts) _, err = secrets.Create(connText, r, opts)
Expect(err).To(Not(BeNil())) Expect(err).To(HaveOccurred())
}) })
It("inspect secret", func() { It("inspect secret", func() {
@ -57,10 +57,10 @@ var _ = Describe("Podman secrets", func() {
Name: &name, Name: &name,
} }
_, err := secrets.Create(connText, r, opts) _, err := secrets.Create(connText, r, opts)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
data, err := secrets.Inspect(connText, name, nil) data, err := secrets.Inspect(connText, name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(data.Spec.Name).To(Equal(name)) Expect(data.Spec.Name).To(Equal(name))
// inspecting non-existent secret should fail // inspecting non-existent secret should fail
@ -76,10 +76,10 @@ var _ = Describe("Podman secrets", func() {
Name: &name, Name: &name,
} }
_, err := secrets.Create(connText, r, opts) _, err := secrets.Create(connText, r, opts)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
data, err := secrets.List(connText, nil) data, err := secrets.List(connText, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(data[0].Spec.Name).To(Equal(name)) Expect(data[0].Spec.Name).To(Equal(name))
}) })
@ -90,7 +90,7 @@ var _ = Describe("Podman secrets", func() {
Name: &name, Name: &name,
} }
_, err := secrets.Create(connText, r, opts) _, err := secrets.Create(connText, r, opts)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
r2 := strings.NewReader("mysecret2") r2 := strings.NewReader("mysecret2")
name2 := "mysecret2" name2 := "mysecret2"
@ -98,17 +98,17 @@ var _ = Describe("Podman secrets", func() {
Name: &name2, Name: &name2,
} }
_, err = secrets.Create(connText, r2, opts2) _, err = secrets.Create(connText, r2, opts2)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
data, err := secrets.List(connText, nil) data, err := secrets.List(connText, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(len(data)).To(Equal(2)) Expect(data).To(HaveLen(2))
}) })
It("list no secrets", func() { It("list no secrets", func() {
data, err := secrets.List(connText, nil) data, err := secrets.List(connText, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(len(data)).To(Equal(0)) Expect(data).To(BeEmpty())
}) })
It("remove secret", func() { It("remove secret", func() {
@ -118,14 +118,14 @@ var _ = Describe("Podman secrets", func() {
Name: &name, Name: &name,
} }
_, err := secrets.Create(connText, r, opts) _, err := secrets.Create(connText, r, opts)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
err = secrets.Remove(connText, name) err = secrets.Remove(connText, name)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// removing non-existent secret should fail // removing non-existent secret should fail
err = secrets.Remove(connText, "nosecret") err = secrets.Remove(connText, "nosecret")
Expect(err).To(Not(BeNil())) Expect(err).To(HaveOccurred())
code, _ := bindings.CheckResponseCode(err) code, _ := bindings.CheckResponseCode(err)
Expect(code).To(BeNumerically("==", http.StatusNotFound)) Expect(code).To(BeNumerically("==", http.StatusNotFound))
}) })

View File

@ -30,7 +30,7 @@ var _ = Describe("Podman system", func() {
s = bt.startAPIService() s = bt.startAPIService()
time.Sleep(1 * time.Second) time.Sleep(1 * time.Second)
err := bt.NewConnection() err := bt.NewConnection()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
}) })
AfterEach(func() { AfterEach(func() {
@ -41,7 +41,7 @@ var _ = Describe("Podman system", func() {
It("podman events", func() { It("podman events", func() {
var name = "top" var name = "top"
_, err := bt.RunTopContainer(&name, nil) _, err := bt.RunTopContainer(&name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
filters := make(map[string][]string) filters := make(map[string][]string)
filters["container"] = []string{name} filters["container"] = []string{name}
@ -58,7 +58,7 @@ var _ = Describe("Podman system", func() {
}() }()
options := new(system.EventsOptions).WithFilters(filters).WithStream(false) options := new(system.EventsOptions).WithFilters(filters).WithStream(false)
err = system.Events(bt.conn, binChan, nil, options) err = system.Events(bt.conn, binChan, nil, options)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
done.Lock() done.Lock()
Expect(eventCounter).To(BeNumerically(">", 0)) Expect(eventCounter).To(BeNumerically(">", 0))
}) })
@ -66,146 +66,146 @@ var _ = Describe("Podman system", func() {
It("podman system prune - pod,container stopped", func() { It("podman system prune - pod,container stopped", func() {
// Start and stop a pod to enter in exited state. // Start and stop a pod to enter in exited state.
_, err := pods.Start(bt.conn, newpod, nil) _, err := pods.Start(bt.conn, newpod, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
_, err = pods.Stop(bt.conn, newpod, nil) _, err = pods.Stop(bt.conn, newpod, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// Start and stop a container to enter in exited state. // Start and stop a container to enter in exited state.
var name = "top" var name = "top"
_, err = bt.RunTopContainer(&name, nil) _, err = bt.RunTopContainer(&name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
err = containers.Stop(bt.conn, name, nil) err = containers.Stop(bt.conn, name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
options := new(system.PruneOptions).WithAll(true) options := new(system.PruneOptions).WithAll(true)
systemPruneResponse, err := system.Prune(bt.conn, options) systemPruneResponse, err := system.Prune(bt.conn, options)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(len(systemPruneResponse.PodPruneReport)).To(Equal(1)) Expect(systemPruneResponse.PodPruneReport).To(HaveLen(1))
Expect(len(systemPruneResponse.ContainerPruneReports)).To(Equal(1)) Expect(systemPruneResponse.ContainerPruneReports).To(HaveLen(1))
Expect(len(systemPruneResponse.ImagePruneReports)). Expect(systemPruneResponse.ImagePruneReports).
To(BeNumerically(">", 0)) ToNot(BeEmpty())
Expect(len(systemPruneResponse.VolumePruneReports)).To(Equal(0)) Expect(systemPruneResponse.VolumePruneReports).To(BeEmpty())
}) })
It("podman system prune running alpine container", func() { It("podman system prune running alpine container", func() {
// Start and stop a pod to enter in exited state. // Start and stop a pod to enter in exited state.
_, err := pods.Start(bt.conn, newpod, nil) _, err := pods.Start(bt.conn, newpod, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
_, err = pods.Stop(bt.conn, newpod, nil) _, err = pods.Stop(bt.conn, newpod, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// Start and stop a container to enter in exited state. // Start and stop a container to enter in exited state.
var name = "top" var name = "top"
_, err = bt.RunTopContainer(&name, nil) _, err = bt.RunTopContainer(&name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
err = containers.Stop(bt.conn, name, nil) err = containers.Stop(bt.conn, name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// Start container and leave in running // Start container and leave in running
var name2 = "top2" var name2 = "top2"
_, err = bt.RunTopContainer(&name2, nil) _, err = bt.RunTopContainer(&name2, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// Adding an unused volume // Adding an unused volume
_, err = volumes.Create(bt.conn, entities.VolumeCreateOptions{}, nil) _, err = volumes.Create(bt.conn, entities.VolumeCreateOptions{}, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
options := new(system.PruneOptions).WithAll(true) options := new(system.PruneOptions).WithAll(true)
systemPruneResponse, err := system.Prune(bt.conn, options) systemPruneResponse, err := system.Prune(bt.conn, options)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(len(systemPruneResponse.PodPruneReport)).To(Equal(1)) Expect(systemPruneResponse.PodPruneReport).To(HaveLen(1))
Expect(len(systemPruneResponse.ContainerPruneReports)).To(Equal(1)) Expect(systemPruneResponse.ContainerPruneReports).To(HaveLen(1))
Expect(len(systemPruneResponse.ImagePruneReports)). Expect(systemPruneResponse.ImagePruneReports).
To(BeNumerically(">", 0)) ToNot(BeEmpty())
// Alpine image should not be pruned as used by running container // Alpine image should not be pruned as used by running container
Expect(reports.PruneReportsIds(systemPruneResponse.ImagePruneReports)). Expect(reports.PruneReportsIds(systemPruneResponse.ImagePruneReports)).
ToNot(ContainElement("docker.io/library/alpine:latest")) ToNot(ContainElement("docker.io/library/alpine:latest"))
// Though unused volume is available it should not be pruned as flag set to false. // Though unused volume is available it should not be pruned as flag set to false.
Expect(len(systemPruneResponse.VolumePruneReports)).To(Equal(0)) Expect(systemPruneResponse.VolumePruneReports).To(BeEmpty())
}) })
It("podman system prune running alpine container volume prune", func() { It("podman system prune running alpine container volume prune", func() {
// Start a pod and leave it running // Start a pod and leave it running
_, err := pods.Start(bt.conn, newpod, nil) _, err := pods.Start(bt.conn, newpod, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// Start and stop a container to enter in exited state. // Start and stop a container to enter in exited state.
var name = "top" var name = "top"
_, err = bt.RunTopContainer(&name, nil) _, err = bt.RunTopContainer(&name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
err = containers.Stop(bt.conn, name, nil) err = containers.Stop(bt.conn, name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// Start second container and leave in running // Start second container and leave in running
var name2 = "top2" var name2 = "top2"
_, err = bt.RunTopContainer(&name2, nil) _, err = bt.RunTopContainer(&name2, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// Adding an unused volume should work // Adding an unused volume should work
_, err = volumes.Create(bt.conn, entities.VolumeCreateOptions{}, nil) _, err = volumes.Create(bt.conn, entities.VolumeCreateOptions{}, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
options := new(system.PruneOptions).WithAll(true).WithVolumes(true) options := new(system.PruneOptions).WithAll(true).WithVolumes(true)
systemPruneResponse, err := system.Prune(bt.conn, options) systemPruneResponse, err := system.Prune(bt.conn, options)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(len(systemPruneResponse.PodPruneReport)).To(Equal(0)) Expect(systemPruneResponse.PodPruneReport).To(BeEmpty())
Expect(len(systemPruneResponse.ContainerPruneReports)).To(Equal(1)) Expect(systemPruneResponse.ContainerPruneReports).To(HaveLen(1))
Expect(len(systemPruneResponse.ImagePruneReports)). Expect(systemPruneResponse.ImagePruneReports).
To(BeNumerically(">", 0)) ToNot(BeEmpty())
// Alpine image should not be pruned as used by running container // Alpine image should not be pruned as used by running container
Expect(reports.PruneReportsIds(systemPruneResponse.ImagePruneReports)). Expect(reports.PruneReportsIds(systemPruneResponse.ImagePruneReports)).
ToNot(ContainElement("docker.io/library/alpine:latest")) ToNot(ContainElement("docker.io/library/alpine:latest"))
// Volume should be pruned now as flag set true // Volume should be pruned now as flag set true
Expect(len(systemPruneResponse.VolumePruneReports)).To(Equal(1)) Expect(systemPruneResponse.VolumePruneReports).To(HaveLen(1))
}) })
It("podman system prune running alpine container volume prune --filter", func() { It("podman system prune running alpine container volume prune --filter", func() {
// Start a pod and leave it running // Start a pod and leave it running
_, err := pods.Start(bt.conn, newpod, nil) _, err := pods.Start(bt.conn, newpod, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// Start and stop a container to enter in exited state. // Start and stop a container to enter in exited state.
var name = "top" var name = "top"
_, err = bt.RunTopContainer(&name, nil) _, err = bt.RunTopContainer(&name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
err = containers.Stop(bt.conn, name, nil) err = containers.Stop(bt.conn, name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// Start second container and leave in running // Start second container and leave in running
var name2 = "top2" var name2 = "top2"
_, err = bt.RunTopContainer(&name2, nil) _, err = bt.RunTopContainer(&name2, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// Adding an unused volume should work // Adding an unused volume should work
_, err = volumes.Create(bt.conn, entities.VolumeCreateOptions{}, nil) _, err = volumes.Create(bt.conn, entities.VolumeCreateOptions{}, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// Adding an unused volume with label should work // Adding an unused volume with label should work
_, err = volumes.Create(bt.conn, entities.VolumeCreateOptions{Label: map[string]string{ _, err = volumes.Create(bt.conn, entities.VolumeCreateOptions{Label: map[string]string{
"label1": "value1", "label1": "value1",
}}, nil) }}, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
f := make(map[string][]string) f := make(map[string][]string)
f["label"] = []string{"label1=idontmatch"} f["label"] = []string{"label1=idontmatch"}
options := new(system.PruneOptions).WithAll(true).WithVolumes(true).WithFilters(f) options := new(system.PruneOptions).WithAll(true).WithVolumes(true).WithFilters(f)
systemPruneResponse, err := system.Prune(bt.conn, options) systemPruneResponse, err := system.Prune(bt.conn, options)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(len(systemPruneResponse.PodPruneReport)).To(Equal(0)) Expect(systemPruneResponse.PodPruneReport).To(BeEmpty())
Expect(len(systemPruneResponse.ContainerPruneReports)).To(Equal(0)) Expect(systemPruneResponse.ContainerPruneReports).To(BeEmpty())
Expect(len(systemPruneResponse.ImagePruneReports)).To(Equal(0)) Expect(systemPruneResponse.ImagePruneReports).To(BeEmpty())
// Alpine image should not be pruned as used by running container // Alpine image should not be pruned as used by running container
Expect(reports.PruneReportsIds(systemPruneResponse.ImagePruneReports)). Expect(reports.PruneReportsIds(systemPruneResponse.ImagePruneReports)).
ToNot(ContainElement("docker.io/library/alpine:latest")) ToNot(ContainElement("docker.io/library/alpine:latest"))
// Volume shouldn't be pruned because the PruneOptions filters doesn't match // Volume shouldn't be pruned because the PruneOptions filters doesn't match
Expect(len(systemPruneResponse.VolumePruneReports)).To(Equal(0)) Expect(systemPruneResponse.VolumePruneReports).To(BeEmpty())
// Fix filter and re prune // Fix filter and re prune
f["label"] = []string{"label1=value1"} f["label"] = []string{"label1=value1"}
options = new(system.PruneOptions).WithAll(true).WithVolumes(true).WithFilters(f) options = new(system.PruneOptions).WithAll(true).WithVolumes(true).WithFilters(f)
systemPruneResponse, err = system.Prune(bt.conn, options) systemPruneResponse, err = system.Prune(bt.conn, options)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// Volume should be pruned because the PruneOptions filters now match // Volume should be pruned because the PruneOptions filters now match
Expect(len(systemPruneResponse.VolumePruneReports)).To(Equal(1)) Expect(systemPruneResponse.VolumePruneReports).To(HaveLen(1))
}) })
}) })

View File

@ -30,7 +30,7 @@ var _ = Describe("Podman volumes", func() {
s = bt.startAPIService() s = bt.startAPIService()
time.Sleep(1 * time.Second) time.Sleep(1 * time.Second)
connText, err = bindings.NewConnection(context.Background(), bt.sock) connText, err = bindings.NewConnection(context.Background(), bt.sock)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
}) })
AfterEach(func() { AfterEach(func() {
@ -41,7 +41,7 @@ var _ = Describe("Podman volumes", func() {
It("create volume", func() { It("create volume", func() {
// create a volume with blank config should work // create a volume with blank config should work
_, err := volumes.Create(connText, entities.VolumeCreateOptions{}, nil) _, err := volumes.Create(connText, entities.VolumeCreateOptions{}, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
vcc := entities.VolumeCreateOptions{ vcc := entities.VolumeCreateOptions{
Name: "foobar", Name: "foobar",
@ -49,21 +49,21 @@ var _ = Describe("Podman volumes", func() {
Options: nil, Options: nil,
} }
vol, err := volumes.Create(connText, vcc, nil) vol, err := volumes.Create(connText, vcc, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(vol.Name).To(Equal("foobar")) Expect(vol.Name).To(Equal("foobar"))
// create volume with same name should 500 // create volume with same name should 500
_, err = volumes.Create(connText, vcc, nil) _, err = volumes.Create(connText, vcc, nil)
Expect(err).ToNot(BeNil()) Expect(err).To(HaveOccurred())
code, _ := bindings.CheckResponseCode(err) code, _ := bindings.CheckResponseCode(err)
Expect(code).To(BeNumerically("==", http.StatusInternalServerError)) Expect(code).To(BeNumerically("==", http.StatusInternalServerError))
}) })
It("inspect volume", func() { It("inspect volume", func() {
vol, err := volumes.Create(connText, entities.VolumeCreateOptions{}, nil) vol, err := volumes.Create(connText, entities.VolumeCreateOptions{}, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
data, err := volumes.Inspect(connText, vol.Name, nil) data, err := volumes.Inspect(connText, vol.Name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(data.Name).To(Equal(vol.Name)) Expect(data.Name).To(Equal(vol.Name))
}) })
@ -71,51 +71,51 @@ var _ = Describe("Podman volumes", func() {
// removing a bogus volume should result in 404 // removing a bogus volume should result in 404
err := volumes.Remove(connText, "foobar", nil) err := volumes.Remove(connText, "foobar", nil)
code, err := bindings.CheckResponseCode(err) code, err := bindings.CheckResponseCode(err)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(code).To(BeNumerically("==", http.StatusNotFound)) Expect(code).To(BeNumerically("==", http.StatusNotFound))
// Removing an unused volume should work // Removing an unused volume should work
vol, err := volumes.Create(connText, entities.VolumeCreateOptions{}, nil) vol, err := volumes.Create(connText, entities.VolumeCreateOptions{}, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
err = volumes.Remove(connText, vol.Name, nil) err = volumes.Remove(connText, vol.Name, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// Removing a volume that is being used without force should be 409 // Removing a volume that is being used without force should be 409
vol, err = volumes.Create(connText, entities.VolumeCreateOptions{}, nil) vol, err = volumes.Create(connText, entities.VolumeCreateOptions{}, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
session := bt.runPodman([]string{"run", "-dt", "-v", fmt.Sprintf("%s:/foobar", vol.Name), "--name", "vtest", alpine.name, "top"}) session := bt.runPodman([]string{"run", "-dt", "-v", fmt.Sprintf("%s:/foobar", vol.Name), "--name", "vtest", alpine.name, "top"})
session.Wait(45) session.Wait(45)
Expect(session.ExitCode()).To(BeZero()) Expect(session.ExitCode()).To(BeZero())
err = volumes.Remove(connText, vol.Name, nil) err = volumes.Remove(connText, vol.Name, nil)
Expect(err).ToNot(BeNil()) Expect(err).To(HaveOccurred())
code, err = bindings.CheckResponseCode(err) code, err = bindings.CheckResponseCode(err)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(code).To(BeNumerically("==", http.StatusConflict)) Expect(code).To(BeNumerically("==", http.StatusConflict))
// Removing with a volume in use with force should work with a stopped container // Removing with a volume in use with force should work with a stopped container
err = containers.Stop(connText, "vtest", new(containers.StopOptions).WithTimeout(0)) err = containers.Stop(connText, "vtest", new(containers.StopOptions).WithTimeout(0))
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
options := new(volumes.RemoveOptions).WithForce(true) options := new(volumes.RemoveOptions).WithForce(true)
err = volumes.Remove(connText, vol.Name, options) err = volumes.Remove(connText, vol.Name, options)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
}) })
It("list volumes", func() { It("list volumes", func() {
// no volumes should be ok // no volumes should be ok
vols, err := volumes.List(connText, nil) vols, err := volumes.List(connText, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(len(vols)).To(BeZero()) Expect(vols).To(BeEmpty())
// create a bunch of named volumes and make verify with list // create a bunch of named volumes and make verify with list
volNames := []string{"homer", "bart", "lisa", "maggie", "marge"} volNames := []string{"homer", "bart", "lisa", "maggie", "marge"}
for i := 0; i < 5; i++ { for i := 0; i < 5; i++ {
_, err = volumes.Create(connText, entities.VolumeCreateOptions{Name: volNames[i]}, nil) _, err = volumes.Create(connText, entities.VolumeCreateOptions{Name: volNames[i]}, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
} }
vols, err = volumes.List(connText, nil) vols, err = volumes.List(connText, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(len(vols)).To(BeNumerically("==", 5)) Expect(vols).To(HaveLen(5))
for _, v := range vols { for _, v := range vols {
Expect(StringInSlice(v.Name, volNames)).To(BeTrue()) Expect(StringInSlice(v.Name, volNames)).To(BeTrue())
} }
@ -125,7 +125,7 @@ var _ = Describe("Podman volumes", func() {
filters["foobar"] = []string{"1234"} filters["foobar"] = []string{"1234"}
options := new(volumes.ListOptions).WithFilters(filters) options := new(volumes.ListOptions).WithFilters(filters)
_, err = volumes.List(connText, options) _, err = volumes.List(connText, options)
Expect(err).ToNot(BeNil()) Expect(err).To(HaveOccurred())
code, _ := bindings.CheckResponseCode(err) code, _ := bindings.CheckResponseCode(err)
Expect(code).To(BeNumerically("==", http.StatusInternalServerError)) Expect(code).To(BeNumerically("==", http.StatusInternalServerError))
@ -133,34 +133,34 @@ var _ = Describe("Podman volumes", func() {
filters["name"] = []string{"homer"} filters["name"] = []string{"homer"}
options = new(volumes.ListOptions).WithFilters(filters) options = new(volumes.ListOptions).WithFilters(filters)
vols, err = volumes.List(connText, options) vols, err = volumes.List(connText, options)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(len(vols)).To(BeNumerically("==", 1)) Expect(vols).To(HaveLen(1))
Expect(vols[0].Name).To(Equal("homer")) Expect(vols[0].Name).To(Equal("homer"))
}) })
It("prune unused volume", func() { It("prune unused volume", func() {
// Pruning when no volumes present should be ok // Pruning when no volumes present should be ok
_, err := volumes.Prune(connText, nil) _, err := volumes.Prune(connText, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// Removing an unused volume should work // Removing an unused volume should work
_, err = volumes.Create(connText, entities.VolumeCreateOptions{}, nil) _, err = volumes.Create(connText, entities.VolumeCreateOptions{}, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
vols, err := volumes.Prune(connText, nil) vols, err := volumes.Prune(connText, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(len(vols)).To(BeNumerically("==", 1)) Expect(vols).To(HaveLen(1))
_, err = volumes.Create(connText, entities.VolumeCreateOptions{Name: "homer"}, nil) _, err = volumes.Create(connText, entities.VolumeCreateOptions{Name: "homer"}, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
_, err = volumes.Create(connText, entities.VolumeCreateOptions{}, nil) _, err = volumes.Create(connText, entities.VolumeCreateOptions{}, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
session := bt.runPodman([]string{"run", "-dt", "-v", fmt.Sprintf("%s:/homer", "homer"), "--name", "vtest", alpine.name, "top"}) session := bt.runPodman([]string{"run", "-dt", "-v", fmt.Sprintf("%s:/homer", "homer"), "--name", "vtest", alpine.name, "top"})
session.Wait(45) session.Wait(45)
vols, err = volumes.Prune(connText, nil) vols, err = volumes.Prune(connText, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(len(reports.PruneReportsIds(vols))).To(BeNumerically("==", 1)) Expect(reports.PruneReportsIds(vols)).To(HaveLen(1))
_, err = volumes.Inspect(connText, "homer", nil) _, err = volumes.Inspect(connText, "homer", nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// Removing volume with non matching filter shouldn't prune any volumes // Removing volume with non matching filter shouldn't prune any volumes
filters := make(map[string][]string) filters := make(map[string][]string)
@ -168,27 +168,27 @@ var _ = Describe("Podman volumes", func() {
_, err = volumes.Create(connText, entities.VolumeCreateOptions{Label: map[string]string{ _, err = volumes.Create(connText, entities.VolumeCreateOptions{Label: map[string]string{
"label1": "value1", "label1": "value1",
}}, nil) }}, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
options := new(volumes.PruneOptions).WithFilters(filters) options := new(volumes.PruneOptions).WithFilters(filters)
vols, err = volumes.Prune(connText, options) vols, err = volumes.Prune(connText, options)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(len(vols)).To(BeNumerically("==", 0)) Expect(vols).To(BeEmpty())
vol2, err := volumes.Create(connText, entities.VolumeCreateOptions{Label: map[string]string{ vol2, err := volumes.Create(connText, entities.VolumeCreateOptions{Label: map[string]string{
"label1": "value2", "label1": "value2",
}}, nil) }}, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
_, err = volumes.Create(connText, entities.VolumeCreateOptions{Label: map[string]string{ _, err = volumes.Create(connText, entities.VolumeCreateOptions{Label: map[string]string{
"label1": "value3", "label1": "value3",
}}, nil) }}, nil)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// Removing volume with matching filter label and value should remove specific entry // Removing volume with matching filter label and value should remove specific entry
filters = make(map[string][]string) filters = make(map[string][]string)
filters["label"] = []string{"label1=value2"} filters["label"] = []string{"label1=value2"}
options = new(volumes.PruneOptions).WithFilters(filters) options = new(volumes.PruneOptions).WithFilters(filters)
vols, err = volumes.Prune(connText, options) vols, err = volumes.Prune(connText, options)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(len(vols)).To(BeNumerically("==", 1)) Expect(vols).To(HaveLen(1))
Expect(vols[0].Id).To(Equal(vol2.Name)) Expect(vols[0].Id).To(Equal(vol2.Name))
// Removing volumes with matching filter label should remove all matching volumes // Removing volumes with matching filter label should remove all matching volumes
@ -196,8 +196,8 @@ var _ = Describe("Podman volumes", func() {
filters["label"] = []string{"label1"} filters["label"] = []string{"label1"}
options = new(volumes.PruneOptions).WithFilters(filters) options = new(volumes.PruneOptions).WithFilters(filters)
vols, err = volumes.Prune(connText, options) vols, err = volumes.Prune(connText, options)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(len(vols)).To(BeNumerically("==", 2)) Expect(vols).To(HaveLen(2))
}) })
}) })

View File

@ -25,27 +25,27 @@ var _ = Describe("run basic podman commands", func() {
name := randomString() name := randomString()
i := new(initMachine) i := new(initMachine)
session, err := mb.setName(name).setCmd(i.withImagePath(mb.imagePath).withNow()).run() session, err := mb.setName(name).setCmd(i.withImagePath(mb.imagePath).withNow()).run()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(session).To(Exit(0)) Expect(session).To(Exit(0))
bm := basicMachine{} bm := basicMachine{}
imgs, err := mb.setCmd(bm.withPodmanCommand([]string{"images", "-q"})).run() imgs, err := mb.setCmd(bm.withPodmanCommand([]string{"images", "-q"})).run()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(imgs).To(Exit(0)) Expect(imgs).To(Exit(0))
Expect(len(imgs.outputToStringSlice())).To(Equal(0)) Expect(imgs.outputToStringSlice()).To(BeEmpty())
newImgs, err := mb.setCmd(bm.withPodmanCommand([]string{"pull", "quay.io/libpod/alpine_nginx"})).run() newImgs, err := mb.setCmd(bm.withPodmanCommand([]string{"pull", "quay.io/libpod/alpine_nginx"})).run()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(newImgs).To(Exit(0)) Expect(newImgs).To(Exit(0))
Expect(len(newImgs.outputToStringSlice())).To(Equal(1)) Expect(newImgs.outputToStringSlice()).To(HaveLen(1))
runAlp, err := mb.setCmd(bm.withPodmanCommand([]string{"run", "quay.io/libpod/alpine_nginx", "cat", "/etc/os-release"})).run() runAlp, err := mb.setCmd(bm.withPodmanCommand([]string{"run", "quay.io/libpod/alpine_nginx", "cat", "/etc/os-release"})).run()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(runAlp).To(Exit(0)) Expect(runAlp).To(Exit(0))
Expect(runAlp.outputToString()).To(ContainSubstring("Alpine Linux")) Expect(runAlp.outputToString()).To(ContainSubstring("Alpine Linux"))
rmCon, err := mb.setCmd(bm.withPodmanCommand([]string{"rm", "-a"})).run() rmCon, err := mb.setCmd(bm.withPodmanCommand([]string{"rm", "-a"})).run()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(rmCon).To(Exit(0)) Expect(rmCon).To(Exit(0))
}) })

View File

@ -37,7 +37,7 @@ var _ = Describe("podman machine info", func() {
// Create a machine and check if info has been updated // Create a machine and check if info has been updated
i := new(initMachine) i := new(initMachine)
initSession, err := mb.setCmd(i.withImagePath(mb.imagePath)).run() initSession, err := mb.setCmd(i.withImagePath(mb.imagePath)).run()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(initSession).To(Exit(0)) Expect(initSession).To(Exit(0))
info = new(infoMachine) info = new(infoMachine)
@ -53,6 +53,6 @@ var _ = Describe("podman machine info", func() {
infoReport := &entities.MachineInfo{} infoReport := &entities.MachineInfo{}
err = jsoniter.Unmarshal(infoSession.Bytes(), infoReport) err = jsoniter.Unmarshal(infoSession.Bytes(), infoReport)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
}) })
}) })

View File

@ -29,20 +29,20 @@ var _ = Describe("podman machine init", func() {
i := initMachine{} i := initMachine{}
reallyLongName := "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" reallyLongName := "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
session, err := mb.setName(reallyLongName).setCmd(&i).run() session, err := mb.setName(reallyLongName).setCmd(&i).run()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(session).To(Exit(125)) Expect(session).To(Exit(125))
}) })
It("simple init", func() { It("simple init", func() {
i := new(initMachine) i := new(initMachine)
session, err := mb.setCmd(i.withImagePath(mb.imagePath)).run() session, err := mb.setCmd(i.withImagePath(mb.imagePath)).run()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(session).To(Exit(0)) Expect(session).To(Exit(0))
inspectBefore, ec, err := mb.toQemuInspectInfo() inspectBefore, ec, err := mb.toQemuInspectInfo()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(ec).To(BeZero()) Expect(ec).To(BeZero())
Expect(len(inspectBefore)).To(BeNumerically(">", 0)) Expect(inspectBefore).ToNot(BeEmpty())
testMachine := inspectBefore[0] testMachine := inspectBefore[0]
Expect(testMachine.Name).To(Equal(mb.names[0])) Expect(testMachine.Name).To(Equal(mb.names[0]))
Expect(testMachine.Resources.CPUs).To(Equal(uint64(1))) Expect(testMachine.Resources.CPUs).To(Equal(uint64(1)))
@ -53,26 +53,26 @@ var _ = Describe("podman machine init", func() {
It("simple init with start", func() { It("simple init with start", func() {
i := initMachine{} i := initMachine{}
session, err := mb.setCmd(i.withImagePath(mb.imagePath)).run() session, err := mb.setCmd(i.withImagePath(mb.imagePath)).run()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(session).To(Exit(0)) Expect(session).To(Exit(0))
inspectBefore, ec, err := mb.toQemuInspectInfo() inspectBefore, ec, err := mb.toQemuInspectInfo()
Expect(ec).To(BeZero()) Expect(ec).To(BeZero())
Expect(len(inspectBefore)).To(BeNumerically(">", 0)) Expect(inspectBefore).ToNot(BeEmpty())
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(len(inspectBefore)).To(BeNumerically(">", 0)) Expect(inspectBefore).ToNot(BeEmpty())
Expect(inspectBefore[0].Name).To(Equal(mb.names[0])) Expect(inspectBefore[0].Name).To(Equal(mb.names[0]))
s := startMachine{} s := startMachine{}
ssession, err := mb.setCmd(s).setTimeout(time.Minute * 10).run() ssession, err := mb.setCmd(s).setTimeout(time.Minute * 10).run()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(ssession).Should(Exit(0)) Expect(ssession).Should(Exit(0))
inspectAfter, ec, err := mb.toQemuInspectInfo() inspectAfter, ec, err := mb.toQemuInspectInfo()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(ec).To(BeZero()) Expect(ec).To(BeZero())
Expect(len(inspectBefore)).To(BeNumerically(">", 0)) Expect(inspectBefore).ToNot(BeEmpty())
Expect(len(inspectAfter)).To(BeNumerically(">", 0)) Expect(inspectAfter).ToNot(BeEmpty())
Expect(inspectAfter[0].State).To(Equal(machine.Running)) Expect(inspectAfter[0].State).To(Equal(machine.Running))
}) })
@ -80,14 +80,14 @@ var _ = Describe("podman machine init", func() {
i := new(initMachine) i := new(initMachine)
remoteUsername := "remoteuser" remoteUsername := "remoteuser"
session, err := mb.setCmd(i.withImagePath(mb.imagePath).withUsername(remoteUsername)).run() session, err := mb.setCmd(i.withImagePath(mb.imagePath).withUsername(remoteUsername)).run()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(session).To(Exit(0)) Expect(session).To(Exit(0))
inspectBefore, ec, err := mb.toQemuInspectInfo() inspectBefore, ec, err := mb.toQemuInspectInfo()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(ec).To(BeZero()) Expect(ec).To(BeZero())
Expect(len(inspectBefore)).To(BeNumerically(">", 0)) Expect(inspectBefore).ToNot(BeEmpty())
testMachine := inspectBefore[0] testMachine := inspectBefore[0]
Expect(testMachine.Name).To(Equal(mb.names[0])) Expect(testMachine.Name).To(Equal(mb.names[0]))
Expect(testMachine.Resources.CPUs).To(Equal(uint64(1))) Expect(testMachine.Resources.CPUs).To(Equal(uint64(1)))
@ -100,64 +100,64 @@ var _ = Describe("podman machine init", func() {
name := randomString() name := randomString()
i := new(initMachine) i := new(initMachine)
session, err := mb.setName(name).setCmd(i.withImagePath(mb.imagePath).withCPUs(2).withDiskSize(102).withMemory(4096).withTimezone("Pacific/Honolulu")).run() session, err := mb.setName(name).setCmd(i.withImagePath(mb.imagePath).withCPUs(2).withDiskSize(102).withMemory(4096).withTimezone("Pacific/Honolulu")).run()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(session).To(Exit(0)) Expect(session).To(Exit(0))
s := new(startMachine) s := new(startMachine)
startSession, err := mb.setCmd(s).run() startSession, err := mb.setCmd(s).run()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(startSession).To(Exit(0)) Expect(startSession).To(Exit(0))
sshCPU := sshMachine{} sshCPU := sshMachine{}
CPUsession, err := mb.setName(name).setCmd(sshCPU.withSSHComand([]string{"lscpu", "|", "grep", "\"CPU(s):\"", "|", "head", "-1"})).run() CPUsession, err := mb.setName(name).setCmd(sshCPU.withSSHComand([]string{"lscpu", "|", "grep", "\"CPU(s):\"", "|", "head", "-1"})).run()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(CPUsession).To(Exit(0)) Expect(CPUsession).To(Exit(0))
Expect(CPUsession.outputToString()).To(ContainSubstring("2")) Expect(CPUsession.outputToString()).To(ContainSubstring("2"))
sshDisk := sshMachine{} sshDisk := sshMachine{}
diskSession, err := mb.setName(name).setCmd(sshDisk.withSSHComand([]string{"sudo", "fdisk", "-l", "|", "grep", "Disk"})).run() diskSession, err := mb.setName(name).setCmd(sshDisk.withSSHComand([]string{"sudo", "fdisk", "-l", "|", "grep", "Disk"})).run()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(diskSession).To(Exit(0)) Expect(diskSession).To(Exit(0))
Expect(diskSession.outputToString()).To(ContainSubstring("102 GiB")) Expect(diskSession.outputToString()).To(ContainSubstring("102 GiB"))
sshMemory := sshMachine{} sshMemory := sshMachine{}
memorySession, err := mb.setName(name).setCmd(sshMemory.withSSHComand([]string{"cat", "/proc/meminfo", "|", "grep", "-i", "'memtotal'", "|", "grep", "-o", "'[[:digit:]]*'"})).run() memorySession, err := mb.setName(name).setCmd(sshMemory.withSSHComand([]string{"cat", "/proc/meminfo", "|", "grep", "-i", "'memtotal'", "|", "grep", "-o", "'[[:digit:]]*'"})).run()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(memorySession).To(Exit(0)) Expect(memorySession).To(Exit(0))
foundMemory, err := strconv.Atoi(memorySession.outputToString()) foundMemory, err := strconv.Atoi(memorySession.outputToString())
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(foundMemory).To(BeNumerically(">", 3800000)) Expect(foundMemory).To(BeNumerically(">", 3800000))
Expect(foundMemory).To(BeNumerically("<", 4200000)) Expect(foundMemory).To(BeNumerically("<", 4200000))
sshTimezone := sshMachine{} sshTimezone := sshMachine{}
timezoneSession, err := mb.setName(name).setCmd(sshTimezone.withSSHComand([]string{"date"})).run() timezoneSession, err := mb.setName(name).setCmd(sshTimezone.withSSHComand([]string{"date"})).run()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(timezoneSession).To(Exit(0)) Expect(timezoneSession).To(Exit(0))
Expect(timezoneSession.outputToString()).To(ContainSubstring("HST")) Expect(timezoneSession.outputToString()).To(ContainSubstring("HST"))
}) })
It("machine init with volume", func() { It("machine init with volume", func() {
tmpDir, err := os.MkdirTemp("", "") tmpDir, err := os.MkdirTemp("", "")
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
_, err = os.CreateTemp(tmpDir, "example") _, err = os.CreateTemp(tmpDir, "example")
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
mount := tmpDir + ":/testmountdir" mount := tmpDir + ":/testmountdir"
defer func() { _ = machine.GuardedRemoveAll(tmpDir) }() defer func() { _ = machine.GuardedRemoveAll(tmpDir) }()
name := randomString() name := randomString()
i := new(initMachine) i := new(initMachine)
session, err := mb.setName(name).setCmd(i.withImagePath(mb.imagePath).withVolume(mount)).run() session, err := mb.setName(name).setCmd(i.withImagePath(mb.imagePath).withVolume(mount)).run()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(session).To(Exit(0)) Expect(session).To(Exit(0))
s := new(startMachine) s := new(startMachine)
startSession, err := mb.setCmd(s).run() startSession, err := mb.setCmd(s).run()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(startSession).To(Exit(0)) Expect(startSession).To(Exit(0))
ssh2 := sshMachine{} ssh2 := sshMachine{}
sshSession2, err := mb.setName(name).setCmd(ssh2.withSSHComand([]string{"ls /testmountdir"})).run() sshSession2, err := mb.setName(name).setCmd(ssh2.withSSHComand([]string{"ls /testmountdir"})).run()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(sshSession2).To(Exit(0)) Expect(sshSession2).To(Exit(0))
Expect(sshSession2.outputToString()).To(ContainSubstring("example")) Expect(sshSession2.outputToString()).To(ContainSubstring("example"))
}) })

View File

@ -28,25 +28,25 @@ var _ = Describe("podman machine stop", func() {
i := inspectMachine{} i := inspectMachine{}
reallyLongName := "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" reallyLongName := "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
session, err := mb.setName(reallyLongName).setCmd(&i).run() session, err := mb.setName(reallyLongName).setCmd(&i).run()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(session).To(Exit(125)) Expect(session).To(Exit(125))
}) })
It("inspect two machines", func() { It("inspect two machines", func() {
i := new(initMachine) i := new(initMachine)
foo1, err := mb.setName("foo1").setCmd(i.withImagePath(mb.imagePath)).run() foo1, err := mb.setName("foo1").setCmd(i.withImagePath(mb.imagePath)).run()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(foo1).To(Exit(0)) Expect(foo1).To(Exit(0))
ii := new(initMachine) ii := new(initMachine)
foo2, err := mb.setName("foo2").setCmd(ii.withImagePath(mb.imagePath)).run() foo2, err := mb.setName("foo2").setCmd(ii.withImagePath(mb.imagePath)).run()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(foo2).To(Exit(0)) Expect(foo2).To(Exit(0))
inspect := new(inspectMachine) inspect := new(inspectMachine)
inspect = inspect.withFormat("{{.Name}}") inspect = inspect.withFormat("{{.Name}}")
inspectSession, err := mb.setName("foo1").setCmd(inspect).run() inspectSession, err := mb.setName("foo1").setCmd(inspect).run()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(inspectSession).To(Exit(0)) Expect(inspectSession).To(Exit(0))
Expect(inspectSession.Bytes()).To(ContainSubstring("foo1")) Expect(inspectSession.Bytes()).To(ContainSubstring("foo1"))
}) })
@ -55,24 +55,24 @@ var _ = Describe("podman machine stop", func() {
name := randomString() name := randomString()
i := new(initMachine) i := new(initMachine)
session, err := mb.setName(name).setCmd(i.withImagePath(mb.imagePath)).run() session, err := mb.setName(name).setCmd(i.withImagePath(mb.imagePath)).run()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(session).To(Exit(0)) Expect(session).To(Exit(0))
// regular inspect should // regular inspect should
inspectJSON := new(inspectMachine) inspectJSON := new(inspectMachine)
inspectSession, err := mb.setName(name).setCmd(inspectJSON).run() inspectSession, err := mb.setName(name).setCmd(inspectJSON).run()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(inspectSession).To(Exit(0)) Expect(inspectSession).To(Exit(0))
var inspectInfo []machine.InspectInfo var inspectInfo []machine.InspectInfo
err = jsoniter.Unmarshal(inspectSession.Bytes(), &inspectInfo) err = jsoniter.Unmarshal(inspectSession.Bytes(), &inspectInfo)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(strings.HasSuffix(inspectInfo[0].ConnectionInfo.PodmanSocket.GetPath(), "podman.sock")) Expect(strings.HasSuffix(inspectInfo[0].ConnectionInfo.PodmanSocket.GetPath(), "podman.sock"))
inspect := new(inspectMachine) inspect := new(inspectMachine)
inspect = inspect.withFormat("{{.Name}}") inspect = inspect.withFormat("{{.Name}}")
inspectSession, err = mb.setName(name).setCmd(inspect).run() inspectSession, err = mb.setName(name).setCmd(inspect).run()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(inspectSession).To(Exit(0)) Expect(inspectSession).To(Exit(0))
Expect(inspectSession.Bytes()).To(ContainSubstring(name)) Expect(inspectSession.Bytes()).To(ContainSubstring(name))
@ -80,7 +80,7 @@ var _ = Describe("podman machine stop", func() {
inspect = new(inspectMachine) inspect = new(inspectMachine)
inspect = inspect.withFormat("{{.Abcde}}") inspect = inspect.withFormat("{{.Abcde}}")
inspectSession, err = mb.setName(name).setCmd(inspect).run() inspectSession, err = mb.setName(name).setCmd(inspect).run()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(inspectSession).To(Exit(125)) Expect(inspectSession).To(Exit(125))
Expect(inspectSession.errorToString()).To(ContainSubstring("can't evaluate field Abcde in type machine.InspectInfo")) Expect(inspectSession.errorToString()).To(ContainSubstring("can't evaluate field Abcde in type machine.InspectInfo"))
}) })

View File

@ -34,7 +34,7 @@ var _ = Describe("podman machine list", func() {
i := new(initMachine) i := new(initMachine)
session, err := mb.setCmd(i.withImagePath(mb.imagePath)).run() session, err := mb.setCmd(i.withImagePath(mb.imagePath)).run()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(session).To(Exit(0)) Expect(session).To(Exit(0))
secondList, err := mb.setCmd(list).run() secondList, err := mb.setCmd(list).run()
@ -61,11 +61,11 @@ var _ = Describe("podman machine list", func() {
i := new(initMachine) i := new(initMachine)
session, err := mb.setName(name1).setCmd(i.withImagePath(mb.imagePath)).run() session, err := mb.setName(name1).setCmd(i.withImagePath(mb.imagePath)).run()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(session).To(Exit(0)) Expect(session).To(Exit(0))
session2, err := mb.setName(name2).setCmd(i.withImagePath(mb.imagePath)).run() session2, err := mb.setName(name2).setCmd(i.withImagePath(mb.imagePath)).run()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(session2).To(Exit(0)) Expect(session2).To(Exit(0))
secondList, err := mb.setCmd(list.withQuiet()).run() secondList, err := mb.setCmd(list.withQuiet()).run()
@ -82,16 +82,16 @@ var _ = Describe("podman machine list", func() {
It("list machine: check if running while starting", func() { It("list machine: check if running while starting", func() {
i := new(initMachine) i := new(initMachine)
session, err := mb.setCmd(i.withImagePath(mb.imagePath)).run() session, err := mb.setCmd(i.withImagePath(mb.imagePath)).run()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(session).To(Exit(0)) Expect(session).To(Exit(0))
s := new(startMachine) s := new(startMachine)
startSession, err := mb.setCmd(s).runWithoutWait() startSession, err := mb.setCmd(s).runWithoutWait()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
l := new(listMachine) l := new(listMachine)
for i := 0; i < 30; i++ { for i := 0; i < 30; i++ {
listSession, err := mb.setCmd(l).run() listSession, err := mb.setCmd(l).run()
Expect(listSession).To(Exit(0)) Expect(listSession).To(Exit(0))
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
if startSession.ExitCode() == -1 { if startSession.ExitCode() == -1 {
Expect(listSession.outputToString()).NotTo(ContainSubstring("Currently running")) Expect(listSession.outputToString()).NotTo(ContainSubstring("Currently running"))
} else { } else {
@ -102,7 +102,7 @@ var _ = Describe("podman machine list", func() {
Expect(startSession).To(Exit(0)) Expect(startSession).To(Exit(0))
listSession, err := mb.setCmd(l).run() listSession, err := mb.setCmd(l).run()
Expect(listSession).To(Exit(0)) Expect(listSession).To(Exit(0))
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(listSession.outputToString()).To(ContainSubstring("Currently running")) Expect(listSession.outputToString()).To(ContainSubstring("Currently running"))
Expect(listSession.outputToString()).NotTo(ContainSubstring("Less than a second ago")) // check to make sure time created is accurate Expect(listSession.outputToString()).NotTo(ContainSubstring("Less than a second ago")) // check to make sure time created is accurate
}) })
@ -113,7 +113,7 @@ var _ = Describe("podman machine list", func() {
i := new(initMachine) i := new(initMachine)
session, err := mb.setName(name1).setCmd(i.withImagePath(mb.imagePath)).run() session, err := mb.setName(name1).setCmd(i.withImagePath(mb.imagePath)).run()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(session).To(Exit(0)) Expect(session).To(Exit(0))
// go format // go format
@ -131,12 +131,12 @@ var _ = Describe("podman machine list", func() {
list2 := new(listMachine) list2 := new(listMachine)
list2 = list2.withFormat("json") list2 = list2.withFormat("json")
listSession2, err := mb.setCmd(list2).run() listSession2, err := mb.setCmd(list2).run()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(listSession2).To(Exit(0)) Expect(listSession2).To(Exit(0))
var listResponse []*entities.ListReporter var listResponse []*entities.ListReporter
err = jsoniter.Unmarshal(listSession2.Bytes(), &listResponse) err = jsoniter.Unmarshal(listSession2.Bytes(), &listResponse)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// table format includes the header // table format includes the header
list = new(listMachine) list = new(listMachine)

View File

@ -23,46 +23,46 @@ var _ = Describe("podman machine rm", func() {
i := rmMachine{} i := rmMachine{}
reallyLongName := "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" reallyLongName := "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
session, err := mb.setName(reallyLongName).setCmd(&i).run() session, err := mb.setName(reallyLongName).setCmd(&i).run()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(session).To(Exit(125)) Expect(session).To(Exit(125))
}) })
It("Remove machine", func() { It("Remove machine", func() {
i := new(initMachine) i := new(initMachine)
session, err := mb.setCmd(i.withImagePath(mb.imagePath)).run() session, err := mb.setCmd(i.withImagePath(mb.imagePath)).run()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(session).To(Exit(0)) Expect(session).To(Exit(0))
rm := rmMachine{} rm := rmMachine{}
_, err = mb.setCmd(rm.withForce()).run() _, err = mb.setCmd(rm.withForce()).run()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// Inspecting a non-existent machine should fail // Inspecting a non-existent machine should fail
// which means it is gone // which means it is gone
_, ec, err := mb.toQemuInspectInfo() _, ec, err := mb.toQemuInspectInfo()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(ec).To(Equal(125)) Expect(ec).To(Equal(125))
}) })
It("Remove running machine", func() { It("Remove running machine", func() {
i := new(initMachine) i := new(initMachine)
session, err := mb.setCmd(i.withImagePath(mb.imagePath).withNow()).run() session, err := mb.setCmd(i.withImagePath(mb.imagePath).withNow()).run()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(session).To(Exit(0)) Expect(session).To(Exit(0))
rm := new(rmMachine) rm := new(rmMachine)
// Removing a running machine should fail // Removing a running machine should fail
stop, err := mb.setCmd(rm).run() stop, err := mb.setCmd(rm).run()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(stop).To(Exit(125)) Expect(stop).To(Exit(125))
// Removing again with force // Removing again with force
stopAgain, err := mb.setCmd(rm.withForce()).run() stopAgain, err := mb.setCmd(rm.withForce()).run()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(stopAgain).To(Exit(0)) Expect(stopAgain).To(Exit(0))
// Inspect to be dead sure // Inspect to be dead sure
_, ec, err := mb.toQemuInspectInfo() _, ec, err := mb.toQemuInspectInfo()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(ec).To(Equal(125)) Expect(ec).To(Equal(125))
}) })
}) })

View File

@ -25,48 +25,48 @@ var _ = Describe("podman machine set", func() {
name := randomString() name := randomString()
i := new(initMachine) i := new(initMachine)
session, err := mb.setName(name).setCmd(i.withImagePath(mb.imagePath)).run() session, err := mb.setName(name).setCmd(i.withImagePath(mb.imagePath)).run()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(session).To(Exit(0)) Expect(session).To(Exit(0))
set := setMachine{} set := setMachine{}
setSession, err := mb.setName(name).setCmd(set.withCPUs(2).withDiskSize(102).withMemory(4096)).run() setSession, err := mb.setName(name).setCmd(set.withCPUs(2).withDiskSize(102).withMemory(4096)).run()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(setSession).To(Exit(0)) Expect(setSession).To(Exit(0))
// shrinking disk size is verboten // shrinking disk size is verboten
shrink, err := mb.setName(name).setCmd(set.withDiskSize(5)).run() shrink, err := mb.setName(name).setCmd(set.withDiskSize(5)).run()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(shrink).To(Exit(125)) Expect(shrink).To(Exit(125))
s := new(startMachine) s := new(startMachine)
startSession, err := mb.setCmd(s).run() startSession, err := mb.setCmd(s).run()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(startSession).To(Exit(0)) Expect(startSession).To(Exit(0))
sshCPU := sshMachine{} sshCPU := sshMachine{}
CPUsession, err := mb.setName(name).setCmd(sshCPU.withSSHComand([]string{"lscpu", "|", "grep", "\"CPU(s):\"", "|", "head", "-1"})).run() CPUsession, err := mb.setName(name).setCmd(sshCPU.withSSHComand([]string{"lscpu", "|", "grep", "\"CPU(s):\"", "|", "head", "-1"})).run()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(CPUsession).To(Exit(0)) Expect(CPUsession).To(Exit(0))
Expect(CPUsession.outputToString()).To(ContainSubstring("2")) Expect(CPUsession.outputToString()).To(ContainSubstring("2"))
sshDisk := sshMachine{} sshDisk := sshMachine{}
diskSession, err := mb.setName(name).setCmd(sshDisk.withSSHComand([]string{"sudo", "fdisk", "-l", "|", "grep", "Disk"})).run() diskSession, err := mb.setName(name).setCmd(sshDisk.withSSHComand([]string{"sudo", "fdisk", "-l", "|", "grep", "Disk"})).run()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(diskSession).To(Exit(0)) Expect(diskSession).To(Exit(0))
Expect(diskSession.outputToString()).To(ContainSubstring("102 GiB")) Expect(diskSession.outputToString()).To(ContainSubstring("102 GiB"))
sshMemory := sshMachine{} sshMemory := sshMachine{}
memorySession, err := mb.setName(name).setCmd(sshMemory.withSSHComand([]string{"cat", "/proc/meminfo", "|", "grep", "-i", "'memtotal'", "|", "grep", "-o", "'[[:digit:]]*'"})).run() memorySession, err := mb.setName(name).setCmd(sshMemory.withSSHComand([]string{"cat", "/proc/meminfo", "|", "grep", "-i", "'memtotal'", "|", "grep", "-o", "'[[:digit:]]*'"})).run()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(memorySession).To(Exit(0)) Expect(memorySession).To(Exit(0))
foundMemory, err := strconv.Atoi(memorySession.outputToString()) foundMemory, err := strconv.Atoi(memorySession.outputToString())
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(foundMemory).To(BeNumerically(">", 3800000)) Expect(foundMemory).To(BeNumerically(">", 3800000))
Expect(foundMemory).To(BeNumerically("<", 4200000)) Expect(foundMemory).To(BeNumerically("<", 4200000))
// Setting a running machine results in 125 // Setting a running machine results in 125
runner, err := mb.setName(name).setCmd(set.withCPUs(4)).run() runner, err := mb.setName(name).setCmd(set.withCPUs(4)).run()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(runner).To(Exit(125)) Expect(runner).To(Exit(125))
}) })
@ -74,28 +74,28 @@ var _ = Describe("podman machine set", func() {
name := randomString() name := randomString()
i := new(initMachine) i := new(initMachine)
session, err := mb.setName(name).setCmd(i.withImagePath(mb.imagePath)).run() session, err := mb.setName(name).setCmd(i.withImagePath(mb.imagePath)).run()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(session).To(Exit(0)) Expect(session).To(Exit(0))
set := setMachine{} set := setMachine{}
setSession, err := mb.setName(name).setCmd(&set).run() setSession, err := mb.setName(name).setCmd(&set).run()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(setSession).To(Exit(0)) Expect(setSession).To(Exit(0))
s := new(startMachine) s := new(startMachine)
startSession, err := mb.setCmd(s).run() startSession, err := mb.setCmd(s).run()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(startSession).To(Exit(0)) Expect(startSession).To(Exit(0))
ssh2 := sshMachine{} ssh2 := sshMachine{}
sshSession2, err := mb.setName(name).setCmd(ssh2.withSSHComand([]string{"lscpu", "|", "grep", "\"CPU(s):\"", "|", "head", "-1"})).run() sshSession2, err := mb.setName(name).setCmd(ssh2.withSSHComand([]string{"lscpu", "|", "grep", "\"CPU(s):\"", "|", "head", "-1"})).run()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(sshSession2).To(Exit(0)) Expect(sshSession2).To(Exit(0))
Expect(sshSession2.outputToString()).To(ContainSubstring("1")) Expect(sshSession2.outputToString()).To(ContainSubstring("1"))
ssh3 := sshMachine{} ssh3 := sshMachine{}
sshSession3, err := mb.setName(name).setCmd(ssh3.withSSHComand([]string{"sudo", "fdisk", "-l", "|", "grep", "Disk"})).run() sshSession3, err := mb.setName(name).setCmd(ssh3.withSSHComand([]string{"sudo", "fdisk", "-l", "|", "grep", "Disk"})).run()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(sshSession3).To(Exit(0)) Expect(sshSession3).To(Exit(0))
Expect(sshSession3.outputToString()).To(ContainSubstring("100 GiB")) Expect(sshSession3.outputToString()).To(ContainSubstring("100 GiB"))
}) })

View File

@ -23,7 +23,7 @@ var _ = Describe("podman machine ssh", func() {
name := randomString() name := randomString()
ssh := sshMachine{} ssh := sshMachine{}
session, err := mb.setName(name).setCmd(ssh).run() session, err := mb.setName(name).setCmd(ssh).run()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(session).To(Exit(125)) Expect(session).To(Exit(125))
Expect(session.errorToString()).To(ContainSubstring("not exist")) Expect(session.errorToString()).To(ContainSubstring("not exist"))
}) })
@ -32,12 +32,12 @@ var _ = Describe("podman machine ssh", func() {
name := randomString() name := randomString()
i := new(initMachine) i := new(initMachine)
session, err := mb.setName(name).setCmd(i.withImagePath(mb.imagePath)).run() session, err := mb.setName(name).setCmd(i.withImagePath(mb.imagePath)).run()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(session).To(Exit(0)) Expect(session).To(Exit(0))
ssh := sshMachine{} ssh := sshMachine{}
sshSession, err := mb.setName(name).setCmd(ssh).run() sshSession, err := mb.setName(name).setCmd(ssh).run()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(sshSession.errorToString()).To(ContainSubstring("is not running")) Expect(sshSession.errorToString()).To(ContainSubstring("is not running"))
Expect(sshSession).To(Exit(125)) Expect(sshSession).To(Exit(125))
}) })
@ -46,18 +46,18 @@ var _ = Describe("podman machine ssh", func() {
name := randomString() name := randomString()
i := new(initMachine) i := new(initMachine)
session, err := mb.setName(name).setCmd(i.withImagePath(mb.imagePath).withNow()).run() session, err := mb.setName(name).setCmd(i.withImagePath(mb.imagePath).withNow()).run()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(session).To(Exit(0)) Expect(session).To(Exit(0))
ssh := sshMachine{} ssh := sshMachine{}
sshSession, err := mb.setName(name).setCmd(ssh.withSSHComand([]string{"cat", "/etc/os-release"})).run() sshSession, err := mb.setName(name).setCmd(ssh.withSSHComand([]string{"cat", "/etc/os-release"})).run()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(sshSession).To(Exit(0)) Expect(sshSession).To(Exit(0))
Expect(sshSession.outputToString()).To(ContainSubstring("Fedora CoreOS")) Expect(sshSession.outputToString()).To(ContainSubstring("Fedora CoreOS"))
// keep exit code // keep exit code
sshSession, err = mb.setName(name).setCmd(ssh.withSSHComand([]string{"false"})).run() sshSession, err = mb.setName(name).setCmd(ssh.withSSHComand([]string{"false"})).run()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(sshSession).To(Exit(1)) Expect(sshSession).To(Exit(1))
Expect(sshSession.outputToString()).To(Equal("")) Expect(sshSession.outputToString()).To(Equal(""))
Expect(sshSession.errorToString()).To(Equal("")) Expect(sshSession.errorToString()).To(Equal(""))

View File

@ -22,36 +22,36 @@ var _ = Describe("podman machine start", func() {
It("start simple machine", func() { It("start simple machine", func() {
i := new(initMachine) i := new(initMachine)
session, err := mb.setCmd(i.withImagePath(mb.imagePath)).run() session, err := mb.setCmd(i.withImagePath(mb.imagePath)).run()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(session).To(Exit(0)) Expect(session).To(Exit(0))
s := new(startMachine) s := new(startMachine)
startSession, err := mb.setCmd(s).run() startSession, err := mb.setCmd(s).run()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(startSession).To(Exit(0)) Expect(startSession).To(Exit(0))
info, ec, err := mb.toQemuInspectInfo() info, ec, err := mb.toQemuInspectInfo()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(ec).To(BeZero()) Expect(ec).To(BeZero())
Expect(info[0].State).To(Equal(machine.Running)) Expect(info[0].State).To(Equal(machine.Running))
stop := new(stopMachine) stop := new(stopMachine)
stopSession, err := mb.setCmd(stop).run() stopSession, err := mb.setCmd(stop).run()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(stopSession).To(Exit(0)) Expect(stopSession).To(Exit(0))
// suppress output // suppress output
startSession, err = mb.setCmd(s.withNoInfo()).run() startSession, err = mb.setCmd(s.withNoInfo()).run()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(startSession).To(Exit(0)) Expect(startSession).To(Exit(0))
Expect(startSession.outputToString()).ToNot(ContainSubstring("API forwarding")) Expect(startSession.outputToString()).ToNot(ContainSubstring("API forwarding"))
stopSession, err = mb.setCmd(stop).run() stopSession, err = mb.setCmd(stop).run()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(stopSession).To(Exit(0)) Expect(stopSession).To(Exit(0))
startSession, err = mb.setCmd(s.withQuiet()).run() startSession, err = mb.setCmd(s.withQuiet()).run()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(startSession).To(Exit(0)) Expect(startSession).To(Exit(0))
Expect(len(startSession.outputToStringSlice())).To(Equal(1)) Expect(startSession.outputToStringSlice()).To(HaveLen(1))
}) })
}) })

View File

@ -23,24 +23,24 @@ var _ = Describe("podman machine stop", func() {
i := stopMachine{} i := stopMachine{}
reallyLongName := "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" reallyLongName := "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
session, err := mb.setName(reallyLongName).setCmd(&i).run() session, err := mb.setName(reallyLongName).setCmd(&i).run()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(session).To(Exit(125)) Expect(session).To(Exit(125))
}) })
It("Stop running machine", func() { It("Stop running machine", func() {
i := new(initMachine) i := new(initMachine)
session, err := mb.setCmd(i.withImagePath(mb.imagePath).withNow()).run() session, err := mb.setCmd(i.withImagePath(mb.imagePath).withNow()).run()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(session).To(Exit(0)) Expect(session).To(Exit(0))
stop := new(stopMachine) stop := new(stopMachine)
stopSession, err := mb.setCmd(stop).run() stopSession, err := mb.setCmd(stop).run()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(stopSession).To(Exit(0)) Expect(stopSession).To(Exit(0))
// Stopping it again should not result in an error // Stopping it again should not result in an error
stopAgain, err := mb.setCmd(stop).run() stopAgain, err := mb.setCmd(stop).run()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(stopAgain).To(Exit((0))) Expect(stopAgain).To(Exit((0)))
}) })
}) })

View File

@ -19,7 +19,7 @@ var _ = Describe("Podman attach", func() {
BeforeEach(func() { BeforeEach(func() {
tempdir, err = CreateTempDirInTempDir() tempdir, err = CreateTempDirInTempDir()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
podmanTest = PodmanTestCreate(tempdir) podmanTest = PodmanTestCreate(tempdir)
podmanTest.Setup() podmanTest.Setup()
}) })

View File

@ -113,7 +113,7 @@ var _ = Describe("Podman build", func() {
Expect(data[0]).To(HaveField("Architecture", runtime.GOARCH)) Expect(data[0]).To(HaveField("Architecture", runtime.GOARCH))
st, err := os.Stat(logfile) st, err := os.Stat(logfile)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(st.Size()).To(Not(Equal(int64(0)))) Expect(st.Size()).To(Not(Equal(int64(0))))
session = podmanTest.Podman([]string{"rmi", "test"}) session = podmanTest.Podman([]string{"rmi", "test"})
@ -207,8 +207,8 @@ var _ = Describe("Podman build", func() {
// Given // Given
// Switch to temp dir and restore it afterwards // Switch to temp dir and restore it afterwards
cwd, err := os.Getwd() cwd, err := os.Getwd()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(os.Chdir(os.TempDir())).To(BeNil()) Expect(os.Chdir(os.TempDir())).To(Succeed())
defer Expect(os.Chdir(cwd)).To(BeNil()) defer Expect(os.Chdir(cwd)).To(BeNil())
// Write target and fake files // Write target and fake files
@ -218,14 +218,14 @@ var _ = Describe("Podman build", func() {
} }
fakeFile := filepath.Join(os.TempDir(), "Containerfile") fakeFile := filepath.Join(os.TempDir(), "Containerfile")
Expect(os.WriteFile(fakeFile, []byte(fmt.Sprintf("FROM %s", ALPINE)), 0755)).To(BeNil()) Expect(os.WriteFile(fakeFile, []byte(fmt.Sprintf("FROM %s", ALPINE)), 0755)).To(Succeed())
targetFile := filepath.Join(targetPath, "Containerfile") targetFile := filepath.Join(targetPath, "Containerfile")
Expect(os.WriteFile(targetFile, []byte("FROM scratch"), 0755)).To(BeNil()) Expect(os.WriteFile(targetFile, []byte("FROM scratch"), 0755)).To(Succeed())
defer func() { defer func() {
Expect(os.RemoveAll(fakeFile)).To(BeNil()) Expect(os.RemoveAll(fakeFile)).To(Succeed())
Expect(os.RemoveAll(targetFile)).To(BeNil()) Expect(os.RemoveAll(targetFile)).To(Succeed())
}() }()
// When // When
@ -243,8 +243,8 @@ var _ = Describe("Podman build", func() {
It("podman build basic alpine and print id to external file", func() { It("podman build basic alpine and print id to external file", func() {
// Switch to temp dir and restore it afterwards // Switch to temp dir and restore it afterwards
cwd, err := os.Getwd() cwd, err := os.Getwd()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(os.Chdir(os.TempDir())).To(BeNil()) Expect(os.Chdir(os.TempDir())).To(Succeed())
defer Expect(os.Chdir(cwd)).To(BeNil()) defer Expect(os.Chdir(cwd)).To(BeNil())
targetPath, err := CreateTempDirInTempDir() targetPath, err := CreateTempDirInTempDir()
@ -311,7 +311,7 @@ RUN printenv http_proxy`, ALPINE)
dockerfilePath := filepath.Join(podmanTest.TempDir, "Dockerfile") dockerfilePath := filepath.Join(podmanTest.TempDir, "Dockerfile")
err := os.WriteFile(dockerfilePath, []byte(dockerfile), 0755) err := os.WriteFile(dockerfilePath, []byte(dockerfile), 0755)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
session := podmanTest.Podman([]string{"build", "--pull-never", "--http-proxy", "--file", dockerfilePath, podmanTest.TempDir}) session := podmanTest.Podman([]string{"build", "--pull-never", "--http-proxy", "--file", dockerfilePath, podmanTest.TempDir})
session.Wait(120) session.Wait(120)
Expect(session).Should(Exit(0)) Expect(session).Should(Exit(0))
@ -330,7 +330,7 @@ RUN exit 5`, ALPINE)
dockerfilePath := filepath.Join(podmanTest.TempDir, "Dockerfile") dockerfilePath := filepath.Join(podmanTest.TempDir, "Dockerfile")
err := os.WriteFile(dockerfilePath, []byte(dockerfile), 0755) err := os.WriteFile(dockerfilePath, []byte(dockerfile), 0755)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
session := podmanTest.Podman([]string{"build", "-t", "error-test", "--file", dockerfilePath, podmanTest.TempDir}) session := podmanTest.Podman([]string{"build", "-t", "error-test", "--file", dockerfilePath, podmanTest.TempDir})
session.Wait(120) session.Wait(120)
Expect(session).Should(Exit(5)) Expect(session).Should(Exit(5))
@ -376,19 +376,19 @@ RUN exit 5`, ALPINE)
// Given // Given
// Switch to temp dir and restore it afterwards // Switch to temp dir and restore it afterwards
cwd, err := os.Getwd() cwd, err := os.Getwd()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
podmanTest.AddImageToRWStore(ALPINE) podmanTest.AddImageToRWStore(ALPINE)
// Write target and fake files // Write target and fake files
targetPath, err := CreateTempDirInTempDir() targetPath, err := CreateTempDirInTempDir()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
targetSubPath := filepath.Join(targetPath, "subdir") targetSubPath := filepath.Join(targetPath, "subdir")
err = os.Mkdir(targetSubPath, 0755) err = os.Mkdir(targetSubPath, 0755)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
dummyFile := filepath.Join(targetSubPath, "dummy") dummyFile := filepath.Join(targetSubPath, "dummy")
err = os.WriteFile(dummyFile, []byte("dummy"), 0644) err = os.WriteFile(dummyFile, []byte("dummy"), 0644)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
containerfile := fmt.Sprintf(`FROM %s containerfile := fmt.Sprintf(`FROM %s
ADD . /test ADD . /test
@ -396,15 +396,15 @@ RUN find /test`, ALPINE)
containerfilePath := filepath.Join(targetPath, "Containerfile") containerfilePath := filepath.Join(targetPath, "Containerfile")
err = os.WriteFile(containerfilePath, []byte(containerfile), 0644) err = os.WriteFile(containerfilePath, []byte(containerfile), 0644)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
defer func() { defer func() {
Expect(os.Chdir(cwd)).To(BeNil()) Expect(os.Chdir(cwd)).To(Succeed())
Expect(os.RemoveAll(targetPath)).To(BeNil()) Expect(os.RemoveAll(targetPath)).To(Succeed())
}() }()
// make cwd as context root path // make cwd as context root path
Expect(os.Chdir(targetPath)).To(BeNil()) Expect(os.Chdir(targetPath)).To(Succeed())
session := podmanTest.Podman([]string{"build", "--pull-never", "-t", "test", "-f", "Containerfile", targetSubPath}) session := podmanTest.Podman([]string{"build", "--pull-never", "-t", "test", "-f", "Containerfile", targetSubPath})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
@ -422,30 +422,30 @@ RUN find /test`, ALPINE)
// Given // Given
// Switch to temp dir and restore it afterwards // Switch to temp dir and restore it afterwards
cwd, err := os.Getwd() cwd, err := os.Getwd()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
podmanTest.AddImageToRWStore(ALPINE) podmanTest.AddImageToRWStore(ALPINE)
// Write target and fake files // Write target and fake files
targetPath, err := CreateTempDirInTempDir() targetPath, err := CreateTempDirInTempDir()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
targetSubPath := filepath.Join(targetPath, "subdir") targetSubPath := filepath.Join(targetPath, "subdir")
err = os.Mkdir(targetSubPath, 0755) err = os.Mkdir(targetSubPath, 0755)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
containerfile := fmt.Sprintf("FROM %s", ALPINE) containerfile := fmt.Sprintf("FROM %s", ALPINE)
containerfilePath := filepath.Join(targetSubPath, "Containerfile") containerfilePath := filepath.Join(targetSubPath, "Containerfile")
err = os.WriteFile(containerfilePath, []byte(containerfile), 0644) err = os.WriteFile(containerfilePath, []byte(containerfile), 0644)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
defer func() { defer func() {
Expect(os.Chdir(cwd)).To(BeNil()) Expect(os.Chdir(cwd)).To(Succeed())
Expect(os.RemoveAll(targetPath)).To(BeNil()) Expect(os.RemoveAll(targetPath)).To(Succeed())
}() }()
// make cwd as context root path // make cwd as context root path
Expect(os.Chdir(targetPath)).To(BeNil()) Expect(os.Chdir(targetPath)).To(Succeed())
session := podmanTest.Podman([]string{"build", "--pull-never", "-t", "test", "-f", "subdir/Containerfile", "."}) session := podmanTest.Podman([]string{"build", "--pull-never", "-t", "test", "-f", "subdir/Containerfile", "."})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
@ -462,13 +462,13 @@ RUN find /test`, ALPINE)
// Given // Given
// Switch to temp dir and restore it afterwards // Switch to temp dir and restore it afterwards
cwd, err := os.Getwd() cwd, err := os.Getwd()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
podmanTest.AddImageToRWStore(ALPINE) podmanTest.AddImageToRWStore(ALPINE)
// Write target and fake files // Write target and fake files
targetPath, err := CreateTempDirInTempDir() targetPath, err := CreateTempDirInTempDir()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
containerfile := fmt.Sprintf(`FROM %s containerfile := fmt.Sprintf(`FROM %s
ADD . /testfilter/ ADD . /testfilter/
@ -476,31 +476,31 @@ RUN find /testfilter/`, ALPINE)
containerfilePath := filepath.Join(targetPath, "Containerfile") containerfilePath := filepath.Join(targetPath, "Containerfile")
err = os.WriteFile(containerfilePath, []byte(containerfile), 0644) err = os.WriteFile(containerfilePath, []byte(containerfile), 0644)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
targetSubPath := filepath.Join(targetPath, "subdir") targetSubPath := filepath.Join(targetPath, "subdir")
err = os.Mkdir(targetSubPath, 0755) err = os.Mkdir(targetSubPath, 0755)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
dummyFile1 := filepath.Join(targetPath, "dummy1") dummyFile1 := filepath.Join(targetPath, "dummy1")
err = os.WriteFile(dummyFile1, []byte("dummy1"), 0644) err = os.WriteFile(dummyFile1, []byte("dummy1"), 0644)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
dummyFile2 := filepath.Join(targetPath, "dummy2") dummyFile2 := filepath.Join(targetPath, "dummy2")
err = os.WriteFile(dummyFile2, []byte("dummy2"), 0644) err = os.WriteFile(dummyFile2, []byte("dummy2"), 0644)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
dummyFile3 := filepath.Join(targetSubPath, "dummy3") dummyFile3 := filepath.Join(targetSubPath, "dummy3")
err = os.WriteFile(dummyFile3, []byte("dummy3"), 0644) err = os.WriteFile(dummyFile3, []byte("dummy3"), 0644)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
defer func() { defer func() {
Expect(os.Chdir(cwd)).To(BeNil()) Expect(os.Chdir(cwd)).To(Succeed())
Expect(os.RemoveAll(targetPath)).To(BeNil()) Expect(os.RemoveAll(targetPath)).To(Succeed())
}() }()
// make cwd as context root path // make cwd as context root path
Expect(os.Chdir(targetPath)).To(BeNil()) Expect(os.Chdir(targetPath)).To(Succeed())
dockerignoreContent := `dummy1 dockerignoreContent := `dummy1
subdir**` subdir**`
@ -509,7 +509,7 @@ subdir**`
// test .dockerignore // test .dockerignore
By("Test .dockererignore") By("Test .dockererignore")
err = os.WriteFile(dockerignoreFile, []byte(dockerignoreContent), 0644) err = os.WriteFile(dockerignoreFile, []byte(dockerignoreContent), 0644)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
session := podmanTest.Podman([]string{"build", "-t", "test", "."}) session := podmanTest.Podman([]string{"build", "-t", "test", "."})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
@ -585,25 +585,25 @@ subdir**`
// Switch to temp dir and restore it afterwards // Switch to temp dir and restore it afterwards
cwd, err := os.Getwd() cwd, err := os.Getwd()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
podmanTest.AddImageToRWStore(ALPINE) podmanTest.AddImageToRWStore(ALPINE)
// Write target and fake files // Write target and fake files
targetPath, err := CreateTempDirInTempDir() targetPath, err := CreateTempDirInTempDir()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
targetSubPath := filepath.Join(targetPath, "subdir") targetSubPath := filepath.Join(targetPath, "subdir")
err = os.Mkdir(targetSubPath, 0755) err = os.Mkdir(targetSubPath, 0755)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
dummyFile := filepath.Join(targetSubPath, "dummy") dummyFile := filepath.Join(targetSubPath, "dummy")
err = os.WriteFile(dummyFile, []byte("dummy"), 0644) err = os.WriteFile(dummyFile, []byte("dummy"), 0644)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
emptyDir := filepath.Join(targetSubPath, "emptyDir") emptyDir := filepath.Join(targetSubPath, "emptyDir")
err = os.Mkdir(emptyDir, 0755) err = os.Mkdir(emptyDir, 0755)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(os.Chdir(targetSubPath)).To(BeNil()) Expect(os.Chdir(targetSubPath)).To(Succeed())
Expect(os.Symlink("dummy", "dummy-symlink")).To(BeNil()) Expect(os.Symlink("dummy", "dummy-symlink")).To(Succeed())
containerfile := fmt.Sprintf(`FROM %s containerfile := fmt.Sprintf(`FROM %s
ADD . /test ADD . /test
@ -612,15 +612,15 @@ RUN [[ -L /test/dummy-symlink ]] && echo SYMLNKOK || echo SYMLNKERR`, ALPINE)
containerfilePath := filepath.Join(targetSubPath, "Containerfile") containerfilePath := filepath.Join(targetSubPath, "Containerfile")
err = os.WriteFile(containerfilePath, []byte(containerfile), 0644) err = os.WriteFile(containerfilePath, []byte(containerfile), 0644)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
defer func() { defer func() {
Expect(os.Chdir(cwd)).To(BeNil()) Expect(os.Chdir(cwd)).To(Succeed())
Expect(os.RemoveAll(targetPath)).To(BeNil()) Expect(os.RemoveAll(targetPath)).To(Succeed())
}() }()
// make cwd as context root path // make cwd as context root path
Expect(os.Chdir(targetPath)).To(BeNil()) Expect(os.Chdir(targetPath)).To(Succeed())
session := podmanTest.Podman([]string{"build", "--pull-never", "-t", "test", targetSubPath}) session := podmanTest.Podman([]string{"build", "--pull-never", "-t", "test", targetSubPath})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
@ -633,17 +633,17 @@ RUN [[ -L /test/dummy-symlink ]] && echo SYMLNKOK || echo SYMLNKERR`, ALPINE)
It("podman build --from, --add-host, --cap-drop, --cap-add", func() { It("podman build --from, --add-host, --cap-drop, --cap-add", func() {
targetPath, err := CreateTempDirInTempDir() targetPath, err := CreateTempDirInTempDir()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
containerFile := filepath.Join(targetPath, "Containerfile") containerFile := filepath.Join(targetPath, "Containerfile")
content := `FROM scratch content := `FROM scratch
RUN cat /etc/hosts RUN cat /etc/hosts
RUN grep CapEff /proc/self/status` RUN grep CapEff /proc/self/status`
Expect(os.WriteFile(containerFile, []byte(content), 0755)).To(BeNil()) Expect(os.WriteFile(containerFile, []byte(content), 0755)).To(Succeed())
defer func() { defer func() {
Expect(os.RemoveAll(containerFile)).To(BeNil()) Expect(os.RemoveAll(containerFile)).To(Succeed())
}() }()
// When // When
@ -664,13 +664,13 @@ RUN grep CapEff /proc/self/status`
It("podman build --isolation && --arch", func() { It("podman build --isolation && --arch", func() {
targetPath, err := CreateTempDirInTempDir() targetPath, err := CreateTempDirInTempDir()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
containerFile := filepath.Join(targetPath, "Containerfile") containerFile := filepath.Join(targetPath, "Containerfile")
Expect(os.WriteFile(containerFile, []byte(fmt.Sprintf("FROM %s", ALPINE)), 0755)).To(BeNil()) Expect(os.WriteFile(containerFile, []byte(fmt.Sprintf("FROM %s", ALPINE)), 0755)).To(Succeed())
defer func() { defer func() {
Expect(os.RemoveAll(containerFile)).To(BeNil()) Expect(os.RemoveAll(containerFile)).To(Succeed())
}() }()
// When // When
@ -712,7 +712,7 @@ RUN echo hello`, ALPINE)
containerfilePath := filepath.Join(podmanTest.TempDir, "Containerfile") containerfilePath := filepath.Join(podmanTest.TempDir, "Containerfile")
err := os.WriteFile(containerfilePath, []byte(containerfile), 0755) err := os.WriteFile(containerfilePath, []byte(containerfile), 0755)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
session := podmanTest.Podman([]string{"build", "--pull-never", "-t", "test", "--timestamp", "0", "--file", containerfilePath, podmanTest.TempDir}) session := podmanTest.Podman([]string{"build", "--pull-never", "-t", "test", "--timestamp", "0", "--file", containerfilePath, podmanTest.TempDir})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0)) Expect(session).Should(Exit(0))
@ -724,12 +724,12 @@ RUN echo hello`, ALPINE)
It("podman build --log-rusage", func() { It("podman build --log-rusage", func() {
targetPath, err := CreateTempDirInTempDir() targetPath, err := CreateTempDirInTempDir()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
containerFile := filepath.Join(targetPath, "Containerfile") containerFile := filepath.Join(targetPath, "Containerfile")
content := `FROM scratch` content := `FROM scratch`
Expect(os.WriteFile(containerFile, []byte(content), 0755)).To(BeNil()) Expect(os.WriteFile(containerFile, []byte(content), 0755)).To(Succeed())
session := podmanTest.Podman([]string{"build", "--log-rusage", "--pull-never", targetPath}) session := podmanTest.Podman([]string{"build", "--log-rusage", "--pull-never", targetPath})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
@ -743,7 +743,7 @@ RUN echo hello`, ALPINE)
containerfile := `FROM scratch` containerfile := `FROM scratch`
containerfilePath := filepath.Join(podmanTest.TempDir, "Containerfile") containerfilePath := filepath.Join(podmanTest.TempDir, "Containerfile")
err := os.WriteFile(containerfilePath, []byte(containerfile), 0755) err := os.WriteFile(containerfilePath, []byte(containerfile), 0755)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
session := podmanTest.Podman([]string{"build", "--pull-never", "-t", "test", "--arch", "foo", "--os", "bar", "--file", containerfilePath, podmanTest.TempDir}) session := podmanTest.Podman([]string{"build", "--pull-never", "-t", "test", "--arch", "foo", "--os", "bar", "--file", containerfilePath, podmanTest.TempDir})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0)) Expect(session).Should(Exit(0))
@ -762,7 +762,7 @@ RUN echo hello`, ALPINE)
containerfile := `FROM scratch` containerfile := `FROM scratch`
containerfilePath := filepath.Join(podmanTest.TempDir, "Containerfile") containerfilePath := filepath.Join(podmanTest.TempDir, "Containerfile")
err := os.WriteFile(containerfilePath, []byte(containerfile), 0755) err := os.WriteFile(containerfilePath, []byte(containerfile), 0755)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
session := podmanTest.Podman([]string{"build", "--pull-never", "-t", "test", "--os", "windows", "--file", containerfilePath, podmanTest.TempDir}) session := podmanTest.Podman([]string{"build", "--pull-never", "-t", "test", "--os", "windows", "--file", containerfilePath, podmanTest.TempDir})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0)) Expect(session).Should(Exit(0))
@ -785,7 +785,7 @@ RUN echo hello`, ALPINE)
RUN ls /dev/fuse`, ALPINE) RUN ls /dev/fuse`, ALPINE)
containerfilePath := filepath.Join(podmanTest.TempDir, "Containerfile") containerfilePath := filepath.Join(podmanTest.TempDir, "Containerfile")
err := os.WriteFile(containerfilePath, []byte(containerfile), 0755) err := os.WriteFile(containerfilePath, []byte(containerfile), 0755)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
session := podmanTest.Podman([]string{"build", "--pull-never", "-t", "test", "--file", containerfilePath, podmanTest.TempDir}) session := podmanTest.Podman([]string{"build", "--pull-never", "-t", "test", "--file", containerfilePath, podmanTest.TempDir})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(1)) Expect(session).Should(Exit(1))
@ -801,7 +801,7 @@ RUN ls /dev/fuse`, ALPINE)
RUN ls /dev/test1`, ALPINE) RUN ls /dev/test1`, ALPINE)
containerfilePath := filepath.Join(podmanTest.TempDir, "Containerfile") containerfilePath := filepath.Join(podmanTest.TempDir, "Containerfile")
err := os.WriteFile(containerfilePath, []byte(containerfile), 0755) err := os.WriteFile(containerfilePath, []byte(containerfile), 0755)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
session := podmanTest.Podman([]string{"build", "--pull-never", "-t", "test", "--file", containerfilePath, podmanTest.TempDir}) session := podmanTest.Podman([]string{"build", "--pull-never", "-t", "test", "--file", containerfilePath, podmanTest.TempDir})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(1)) Expect(session).Should(Exit(1))
@ -818,11 +818,11 @@ RUN ls /dev/test1`, ALPINE)
buildRoot := filepath.Join(relativeDir, "build-root") buildRoot := filepath.Join(relativeDir, "build-root")
err = os.Mkdir(relativeDir, 0755) err = os.Mkdir(relativeDir, 0755)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
err = os.Mkdir(buildRoot, 0755) err = os.Mkdir(buildRoot, 0755)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
err = os.WriteFile(containerFilePath, []byte(containerFile), 0755) err = os.WriteFile(containerFilePath, []byte(containerFile), 0755)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
build := podmanTest.Podman([]string{"build", "-f", containerFilePath, buildRoot}) build := podmanTest.Podman([]string{"build", "-f", containerFilePath, buildRoot})
build.WaitWithDefaultTimeout() build.WaitWithDefaultTimeout()
Expect(build).To(Exit(0)) Expect(build).To(Exit(0))

View File

@ -59,7 +59,7 @@ var _ = Describe("Podman checkpoint", func() {
SkipIfRootless("checkpoint not supported in rootless mode") SkipIfRootless("checkpoint not supported in rootless mode")
SkipIfContainerized("FIXME: #15015. All checkpoint tests hang when containerized.") SkipIfContainerized("FIXME: #15015. All checkpoint tests hang when containerized.")
tempdir, err = CreateTempDirInTempDir() tempdir, err = CreateTempDirInTempDir()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
podmanTest = PodmanTestCreate(tempdir) podmanTest = PodmanTestCreate(tempdir)
podmanTest.Setup() podmanTest.Setup()
@ -389,7 +389,7 @@ var _ = Describe("Podman checkpoint", func() {
// Open a network connection to the redis server // Open a network connection to the redis server
conn, err := net.DialTimeout("tcp4", IP.OutputToString()+":6379", time.Duration(3)*time.Second) conn, err := net.DialTimeout("tcp4", IP.OutputToString()+":6379", time.Duration(3)*time.Second)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// This should fail as the container has established TCP connections // This should fail as the container has established TCP connections
result := podmanTest.Podman([]string{"container", "checkpoint", cid}) result := podmanTest.Podman([]string{"container", "checkpoint", cid})
@ -1135,7 +1135,7 @@ var _ = Describe("Podman checkpoint", func() {
// Open a network connection to the redis server via initial port mapping // Open a network connection to the redis server via initial port mapping
// This should fail // This should fail
_, err = net.DialTimeout("tcp4", fmt.Sprintf("localhost:%d", randomPort), time.Duration(3)*time.Second) _, err = net.DialTimeout("tcp4", fmt.Sprintf("localhost:%d", randomPort), time.Duration(3)*time.Second)
Expect(err).ToNot(BeNil()) Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("connection refused")) Expect(err.Error()).To(ContainSubstring("connection refused"))
// Open a network connection to the redis server via new port mapping // Open a network connection to the redis server via new port mapping
fmt.Fprintf(os.Stderr, "Trying to reconnect to redis server at localhost:%d", newRandomPort) fmt.Fprintf(os.Stderr, "Trying to reconnect to redis server at localhost:%d", newRandomPort)
@ -1396,7 +1396,7 @@ var _ = Describe("Podman checkpoint", func() {
_, err = os.Stat(filepath.Join(destinationDirectory, stats.StatsDump)) _, err = os.Stat(filepath.Join(destinationDirectory, stats.StatsDump))
Expect(err).ShouldNot(HaveOccurred()) Expect(err).ShouldNot(HaveOccurred())
Expect(os.RemoveAll(destinationDirectory)).To(BeNil()) Expect(os.RemoveAll(destinationDirectory)).To(Succeed())
// Remove exported checkpoint // Remove exported checkpoint
os.Remove(fileName) os.Remove(fileName)

View File

@ -20,7 +20,7 @@ var _ = Describe("Podman commit", func() {
BeforeEach(func() { BeforeEach(func() {
tempdir, err = CreateTempDirInTempDir() tempdir, err = CreateTempDirInTempDir()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
podmanTest = PodmanTestCreate(tempdir) podmanTest = PodmanTestCreate(tempdir)
podmanTest.Setup() podmanTest.Setup()
}) })
@ -127,7 +127,7 @@ var _ = Describe("Podman commit", func() {
break break
} }
} }
Expect(foundBlue).To(Equal(true)) Expect(foundBlue).To(BeTrue())
}) })
It("podman commit container with --squash", func() { It("podman commit container with --squash", func() {
@ -268,8 +268,8 @@ var _ = Describe("Podman commit", func() {
It("podman commit container and print id to external file", func() { It("podman commit container and print id to external file", func() {
// Switch to temp dir and restore it afterwards // Switch to temp dir and restore it afterwards
cwd, err := os.Getwd() cwd, err := os.Getwd()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(os.Chdir(os.TempDir())).To(BeNil()) Expect(os.Chdir(os.TempDir())).To(Succeed())
targetPath, err := CreateTempDirInTempDir() targetPath, err := CreateTempDirInTempDir()
if err != nil { if err != nil {
os.Exit(1) os.Exit(1)
@ -297,7 +297,7 @@ var _ = Describe("Podman commit", func() {
secretsString := "somesecretdata" secretsString := "somesecretdata"
secretFilePath := filepath.Join(podmanTest.TempDir, "secret") secretFilePath := filepath.Join(podmanTest.TempDir, "secret")
err := os.WriteFile(secretFilePath, []byte(secretsString), 0755) err := os.WriteFile(secretFilePath, []byte(secretsString), 0755)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
session := podmanTest.Podman([]string{"secret", "create", "mysecret", secretFilePath}) session := podmanTest.Podman([]string{"secret", "create", "mysecret", secretFilePath})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
@ -322,7 +322,7 @@ var _ = Describe("Podman commit", func() {
secretsString := "somesecretdata" secretsString := "somesecretdata"
secretFilePath := filepath.Join(podmanTest.TempDir, "secret") secretFilePath := filepath.Join(podmanTest.TempDir, "secret")
err := os.WriteFile(secretFilePath, []byte(secretsString), 0755) err := os.WriteFile(secretFilePath, []byte(secretsString), 0755)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
session := podmanTest.Podman([]string{"secret", "create", "mysecret", secretFilePath}) session := podmanTest.Podman([]string{"secret", "create", "mysecret", secretFilePath})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()

View File

@ -382,7 +382,7 @@ func (p *PodmanTestIntegration) createArtifact(image string) {
func (s *PodmanSessionIntegration) InspectImageJSON() []inspect.ImageData { func (s *PodmanSessionIntegration) InspectImageJSON() []inspect.ImageData {
var i []inspect.ImageData var i []inspect.ImageData
err := jsoniter.Unmarshal(s.Out.Contents(), &i) err := jsoniter.Unmarshal(s.Out.Contents(), &i)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
return i return i
} }
@ -582,7 +582,7 @@ func (p *PodmanTestIntegration) CleanupSecrets() {
func (s *PodmanSessionIntegration) InspectContainerToJSON() []define.InspectContainerData { func (s *PodmanSessionIntegration) InspectContainerToJSON() []define.InspectContainerData {
var i []define.InspectContainerData var i []define.InspectContainerData
err := jsoniter.Unmarshal(s.Out.Contents(), &i) err := jsoniter.Unmarshal(s.Out.Contents(), &i)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
return i return i
} }
@ -598,7 +598,7 @@ func (s *PodmanSessionIntegration) InspectPodToJSON() define.InspectPodData {
func (s *PodmanSessionIntegration) InspectPodArrToJSON() []define.InspectPodData { func (s *PodmanSessionIntegration) InspectPodArrToJSON() []define.InspectPodData {
var i []define.InspectPodData var i []define.InspectPodData
err := jsoniter.Unmarshal(s.Out.Contents(), &i) err := jsoniter.Unmarshal(s.Out.Contents(), &i)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
return i return i
} }
@ -826,7 +826,7 @@ func (p *PodmanTestIntegration) RestoreArtifactToCache(image string) error {
func populateCache(podman *PodmanTestIntegration) { func populateCache(podman *PodmanTestIntegration) {
for _, image := range CACHE_IMAGES { for _, image := range CACHE_IMAGES {
err := podman.RestoreArtifactToCache(image) err := podman.RestoreArtifactToCache(image)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
} }
// logformatter uses this to recognize the first test // logformatter uses this to recognize the first test
fmt.Printf("-----------------------------\n") fmt.Printf("-----------------------------\n")
@ -987,7 +987,7 @@ func (s *PodmanSessionIntegration) jq(jqCommand string) (string, error) {
func (p *PodmanTestIntegration) buildImage(dockerfile, imageName string, layers string, label string) string { func (p *PodmanTestIntegration) buildImage(dockerfile, imageName string, layers string, label string) string {
dockerfilePath := filepath.Join(p.TempDir, "Dockerfile") dockerfilePath := filepath.Join(p.TempDir, "Dockerfile")
err := os.WriteFile(dockerfilePath, []byte(dockerfile), 0755) err := os.WriteFile(dockerfilePath, []byte(dockerfile), 0755)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
cmd := []string{"build", "--pull-never", "--layers=" + layers, "--file", dockerfilePath} cmd := []string{"build", "--pull-never", "--layers=" + layers, "--file", dockerfilePath}
if label != "" { if label != "" {
cmd = append(cmd, "--label="+label) cmd = append(cmd, "--label="+label)

View File

@ -15,7 +15,7 @@ func buildDataVolumeImage(pTest *PodmanTestIntegration, image, data, dest string
// Create a dummy file for data volume // Create a dummy file for data volume
dummyFile := filepath.Join(pTest.TempDir, data) dummyFile := filepath.Join(pTest.TempDir, data)
err := os.WriteFile(dummyFile, []byte(data), 0644) err := os.WriteFile(dummyFile, []byte(data), 0644)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// Create a data volume container image but no CMD binary in it // Create a data volume container image but no CMD binary in it
containerFile := fmt.Sprintf(`FROM scratch containerFile := fmt.Sprintf(`FROM scratch
@ -29,7 +29,7 @@ func createContainersConfFile(pTest *PodmanTestIntegration) {
configPath := filepath.Join(pTest.TempDir, "containers.conf") configPath := filepath.Join(pTest.TempDir, "containers.conf")
containersConf := []byte("[containers]\nprepare_volume_on_create = true\n") containersConf := []byte("[containers]\nprepare_volume_on_create = true\n")
err := os.WriteFile(configPath, containersConf, os.ModePerm) err := os.WriteFile(configPath, containersConf, os.ModePerm)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// Set custom containers.conf file // Set custom containers.conf file
os.Setenv("CONTAINERS_CONF", configPath) os.Setenv("CONTAINERS_CONF", configPath)
@ -58,7 +58,7 @@ func checkDataVolumeContainer(pTest *PodmanTestIntegration, image, cont, dest, d
// Check the mount source directory // Check the mount source directory
files, err := os.ReadDir(mntSource) files, err := os.ReadDir(mntSource)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
if data == "" { if data == "" {
Expect(files).To(BeEmpty()) Expect(files).To(BeEmpty())

View File

@ -43,13 +43,13 @@ var _ = Describe("Podman cp", func() {
// that the contents match. // that the contents match.
It("podman cp file", func() { It("podman cp file", func() {
srcFile, err := os.CreateTemp("", "") srcFile, err := os.CreateTemp("", "")
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
defer srcFile.Close() defer srcFile.Close()
defer os.Remove(srcFile.Name()) defer os.Remove(srcFile.Name())
originalContent := []byte("podman cp file test") originalContent := []byte("podman cp file test")
err = os.WriteFile(srcFile.Name(), originalContent, 0644) err = os.WriteFile(srcFile.Name(), originalContent, 0644)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// Create a container. NOTE that container mustn't be running for copying. // Create a container. NOTE that container mustn't be running for copying.
session := podmanTest.Podman([]string{"create", ALPINE}) session := podmanTest.Podman([]string{"create", ALPINE})
@ -72,7 +72,7 @@ var _ = Describe("Podman cp", func() {
// Copy FROM the container. // Copy FROM the container.
destFile, err := os.CreateTemp("", "") destFile, err := os.CreateTemp("", "")
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
defer destFile.Close() defer destFile.Close()
defer os.Remove(destFile.Name()) defer os.Remove(destFile.Name())
@ -86,7 +86,7 @@ var _ = Describe("Podman cp", func() {
// Now make sure the content matches. // Now make sure the content matches.
roundtripContent, err := os.ReadFile(destFile.Name()) roundtripContent, err := os.ReadFile(destFile.Name())
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(roundtripContent).To(Equal(originalContent)) Expect(roundtripContent).To(Equal(originalContent))
}) })
@ -94,13 +94,13 @@ var _ = Describe("Podman cp", func() {
It("podman cp --pid=host file", func() { It("podman cp --pid=host file", func() {
SkipIfRootlessCgroupsV1("Not supported for rootless + CgroupsV1") SkipIfRootlessCgroupsV1("Not supported for rootless + CgroupsV1")
srcFile, err := os.CreateTemp("", "") srcFile, err := os.CreateTemp("", "")
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
defer srcFile.Close() defer srcFile.Close()
defer os.Remove(srcFile.Name()) defer os.Remove(srcFile.Name())
originalContent := []byte("podman cp file test") originalContent := []byte("podman cp file test")
err = os.WriteFile(srcFile.Name(), originalContent, 0644) err = os.WriteFile(srcFile.Name(), originalContent, 0644)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// Create a container. NOTE that container mustn't be running for copying. // Create a container. NOTE that container mustn't be running for copying.
session := podmanTest.Podman([]string{"create", "--pid=host", ALPINE, "top"}) session := podmanTest.Podman([]string{"create", "--pid=host", ALPINE, "top"})
@ -120,7 +120,7 @@ var _ = Describe("Podman cp", func() {
// Copy FROM the container. // Copy FROM the container.
destFile, err := os.CreateTemp("", "") destFile, err := os.CreateTemp("", "")
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
defer destFile.Close() defer destFile.Close()
defer os.Remove(destFile.Name()) defer os.Remove(destFile.Name())
@ -130,7 +130,7 @@ var _ = Describe("Podman cp", func() {
// Now make sure the content matches. // Now make sure the content matches.
roundtripContent, err := os.ReadFile(destFile.Name()) roundtripContent, err := os.ReadFile(destFile.Name())
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(roundtripContent).To(Equal(originalContent)) Expect(roundtripContent).To(Equal(originalContent))
}) })
@ -139,13 +139,13 @@ var _ = Describe("Podman cp", func() {
// give the right content. // give the right content.
It("podman cp symlink", func() { It("podman cp symlink", func() {
srcFile, err := os.CreateTemp("", "") srcFile, err := os.CreateTemp("", "")
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
defer srcFile.Close() defer srcFile.Close()
defer os.Remove(srcFile.Name()) defer os.Remove(srcFile.Name())
originalContent := []byte("podman cp symlink test") originalContent := []byte("podman cp symlink test")
err = os.WriteFile(srcFile.Name(), originalContent, 0644) err = os.WriteFile(srcFile.Name(), originalContent, 0644)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
session := podmanTest.Podman([]string{"run", "-d", ALPINE, "top"}) session := podmanTest.Podman([]string{"run", "-d", ALPINE, "top"})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
@ -178,13 +178,13 @@ var _ = Describe("Podman cp", func() {
// data to the volume and not the container. // data to the volume and not the container.
It("podman cp volume", func() { It("podman cp volume", func() {
srcFile, err := os.CreateTemp("", "") srcFile, err := os.CreateTemp("", "")
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
defer srcFile.Close() defer srcFile.Close()
defer os.Remove(srcFile.Name()) defer os.Remove(srcFile.Name())
originalContent := []byte("podman cp volume") originalContent := []byte("podman cp volume")
err = os.WriteFile(srcFile.Name(), originalContent, 0644) err = os.WriteFile(srcFile.Name(), originalContent, 0644)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
session := podmanTest.Podman([]string{"volume", "create", "data"}) session := podmanTest.Podman([]string{"volume", "create", "data"})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0)) Expect(session).Should(Exit(0))
@ -205,7 +205,7 @@ var _ = Describe("Podman cp", func() {
volumeMountPoint := session.OutputToString() volumeMountPoint := session.OutputToString()
copiedContent, err := os.ReadFile(filepath.Join(volumeMountPoint, "file.txt")) copiedContent, err := os.ReadFile(filepath.Join(volumeMountPoint, "file.txt"))
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(copiedContent).To(Equal(originalContent)) Expect(copiedContent).To(Equal(originalContent))
}) })
@ -214,7 +214,7 @@ var _ = Describe("Podman cp", func() {
// access it, and (roughly) the right users own it. // access it, and (roughly) the right users own it.
It("podman cp from ctr chown ", func() { It("podman cp from ctr chown ", func() {
srcFile, err := os.CreateTemp("", "") srcFile, err := os.CreateTemp("", "")
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
defer srcFile.Close() defer srcFile.Close()
defer os.Remove(srcFile.Name()) defer os.Remove(srcFile.Name())
@ -236,10 +236,10 @@ var _ = Describe("Podman cp", func() {
// owner of the file copied to local machine is not testuser // owner of the file copied to local machine is not testuser
u, err := user.Current() u, err := user.Current()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
cmd := exec.Command("ls", "-l", srcFile.Name()) cmd := exec.Command("ls", "-l", srcFile.Name())
cmdRet, err := cmd.Output() cmdRet, err := cmd.Output()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(string(cmdRet)).To(ContainSubstring(u.Username)) Expect(string(cmdRet)).To(ContainSubstring(u.Username))
session = podmanTest.Podman([]string{"cp", "--pause=false", srcFile.Name(), "testctr:testfile2"}) session = podmanTest.Podman([]string{"cp", "--pause=false", srcFile.Name(), "testctr:testfile2"})
@ -265,7 +265,7 @@ var _ = Describe("Podman cp", func() {
Expect(session).Should(Exit(0)) Expect(session).Should(Exit(0))
tmpDir, err := os.MkdirTemp("", "") tmpDir, err := os.MkdirTemp("", "")
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
session = podmanTest.Podman([]string{"cp", container + ":/", tmpDir}) session = podmanTest.Podman([]string{"cp", container + ":/", tmpDir})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
@ -274,7 +274,7 @@ var _ = Describe("Podman cp", func() {
cmd := exec.Command("ls", "-la", tmpDir) cmd := exec.Command("ls", "-la", tmpDir)
output, err := cmd.Output() output, err := cmd.Output()
lsOutput := string(output) lsOutput := string(output)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(lsOutput).To(ContainSubstring("dummy.txt")) Expect(lsOutput).To(ContainSubstring("dummy.txt"))
Expect(lsOutput).To(ContainSubstring("tmp")) Expect(lsOutput).To(ContainSubstring("tmp"))
Expect(lsOutput).To(ContainSubstring("etc")) Expect(lsOutput).To(ContainSubstring("etc"))

View File

@ -23,7 +23,7 @@ var _ = Describe("Podman create", func() {
BeforeEach(func() { BeforeEach(func() {
tempdir, err = CreateTempDirInTempDir() tempdir, err = CreateTempDirInTempDir()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
podmanTest = PodmanTestCreate(tempdir) podmanTest = PodmanTestCreate(tempdir)
podmanTest.Setup() podmanTest.Setup()
}) })
@ -146,10 +146,10 @@ var _ = Describe("Podman create", func() {
It("podman create --mount flag with multiple mounts", func() { It("podman create --mount flag with multiple mounts", func() {
vol1 := filepath.Join(podmanTest.TempDir, "vol-test1") vol1 := filepath.Join(podmanTest.TempDir, "vol-test1")
err := os.MkdirAll(vol1, 0755) err := os.MkdirAll(vol1, 0755)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
vol2 := filepath.Join(podmanTest.TempDir, "vol-test2") vol2 := filepath.Join(podmanTest.TempDir, "vol-test2")
err = os.MkdirAll(vol2, 0755) err = os.MkdirAll(vol2, 0755)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
session := podmanTest.Podman([]string{"create", "--name", "test", "--mount", "type=bind,src=" + vol1 + ",target=/myvol1,z", "--mount", "type=bind,src=" + vol2 + ",target=/myvol2,z", ALPINE, "touch", "/myvol2/foo.txt"}) session := podmanTest.Podman([]string{"create", "--name", "test", "--mount", "type=bind,src=" + vol1 + ",target=/myvol1,z", "--mount", "type=bind,src=" + vol2 + ",target=/myvol2,z", ALPINE, "touch", "/myvol2/foo.txt"})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
@ -224,7 +224,7 @@ var _ = Describe("Podman create", func() {
Expect(session).Should(Exit(125)) Expect(session).Should(Exit(125))
tmpDir, err := os.MkdirTemp("", "") tmpDir, err := os.MkdirTemp("", "")
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
defer os.RemoveAll(tmpDir) defer os.RemoveAll(tmpDir)
podName := "rudolph" podName := "rudolph"

View File

@ -39,7 +39,7 @@ var _ = Describe("Podman diff", func() {
session := podmanTest.Podman([]string{"diff", ALPINE}) session := podmanTest.Podman([]string{"diff", ALPINE})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0)) Expect(session).Should(Exit(0))
Expect(len(session.OutputToStringArray())).To(BeNumerically(">", 0)) Expect(session.OutputToStringArray()).ToNot(BeEmpty())
}) })
It("podman diff bogus image", func() { It("podman diff bogus image", func() {
@ -135,7 +135,7 @@ RUN echo test
session := podmanTest.Podman([]string{"image", "diff", BB}) session := podmanTest.Podman([]string{"image", "diff", BB})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0)) Expect(session).Should(Exit(0))
Expect(len(session.OutputToStringArray())).To(BeNumerically(">", 0)) Expect(session.OutputToStringArray()).ToNot(BeEmpty())
}) })
It("podman image diff bogus image", func() { It("podman image diff bogus image", func() {

View File

@ -56,7 +56,7 @@ var _ = Describe("Podman events", func() {
result := podmanTest.Podman([]string{"events", "--stream=false", "--filter", "event=start"}) result := podmanTest.Podman([]string{"events", "--stream=false", "--filter", "event=start"})
result.WaitWithDefaultTimeout() result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0)) Expect(result).Should(Exit(0))
Expect(len(result.OutputToStringArray())).To(BeNumerically(">=", 1), "Number of events") Expect(result.OutputToStringArray()).ToNot(BeEmpty(), "Number of events")
date := time.Now().Format("2006-01-02") date := time.Now().Format("2006-01-02")
Expect(result.OutputToStringArray()).To(ContainElement(HavePrefix(date)), "event log has correct timestamp") Expect(result.OutputToStringArray()).To(ContainElement(HavePrefix(date)), "event log has correct timestamp")
}) })
@ -194,7 +194,7 @@ var _ = Describe("Podman events", func() {
tEnd := time.Now() tEnd := time.Now()
outDur := tEnd.Sub(untilT) outDur := tEnd.Sub(untilT)
diff := outDur.Seconds() > 0 diff := outDur.Seconds() > 0
Expect(diff).To(Equal(true)) Expect(diff).To(BeTrue())
Expect(result.OutputToString()).To(ContainSubstring(name1)) Expect(result.OutputToString()).To(ContainSubstring(name1))
Expect(result.OutputToString()).To(ContainSubstring(name2)) Expect(result.OutputToString()).To(ContainSubstring(name2))
Expect(result.OutputToString()).To(ContainSubstring(name3)) Expect(result.OutputToString()).To(ContainSubstring(name3))
@ -242,7 +242,7 @@ var _ = Describe("Podman events", func() {
result := podmanTest.Podman([]string{"events", "--stream=false", "--filter", "event=health_status", "--since", "1m"}) result := podmanTest.Podman([]string{"events", "--stream=false", "--filter", "event=health_status", "--since", "1m"})
result.WaitWithDefaultTimeout() result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0)) Expect(result).Should(Exit(0))
Expect(len(result.OutputToStringArray())).To(BeNumerically(">=", 1), "Number of health_status events") Expect(result.OutputToStringArray()).ToNot(BeEmpty(), "Number of health_status events")
}) })
}) })

View File

@ -453,7 +453,7 @@ var _ = Describe("Podman exec", func() {
Expect(setup).Should(Exit(0)) Expect(setup).Should(Exit(0))
devNull, err := os.Open("/dev/null") devNull, err := os.Open("/dev/null")
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
defer devNull.Close() defer devNull.Close()
files := []*os.File{ files := []*os.File{
devNull, devNull,
@ -545,7 +545,7 @@ RUN useradd -u 1000 auser`, fedoraMinimal)
secretsString := "somesecretdata" secretsString := "somesecretdata"
secretFilePath := filepath.Join(podmanTest.TempDir, "secret") secretFilePath := filepath.Join(podmanTest.TempDir, "secret")
err := os.WriteFile(secretFilePath, []byte(secretsString), 0755) err := os.WriteFile(secretFilePath, []byte(secretsString), 0755)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
session := podmanTest.Podman([]string{"secret", "create", "mysecret", secretFilePath}) session := podmanTest.Podman([]string{"secret", "create", "mysecret", secretFilePath})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()

View File

@ -42,10 +42,10 @@ var _ = Describe("Podman export", func() {
result.WaitWithDefaultTimeout() result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0)) Expect(result).Should(Exit(0))
_, err := os.Stat(outfile) _, err := os.Stat(outfile)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
err = os.Remove(outfile) err = os.Remove(outfile)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
}) })
It("podman container export output flag", func() { It("podman container export output flag", func() {
@ -57,10 +57,10 @@ var _ = Describe("Podman export", func() {
result.WaitWithDefaultTimeout() result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0)) Expect(result).Should(Exit(0))
_, err := os.Stat(outfile) _, err := os.Stat(outfile)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
err = os.Remove(outfile) err = os.Remove(outfile)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
}) })
It("podman export bad filename", func() { It("podman export bad filename", func() {

View File

@ -64,7 +64,7 @@ var _ = Describe("Podman generate kube", func() {
pod := new(v1.Pod) pod := new(v1.Pod)
err := yaml.Unmarshal(kube.Out.Contents(), pod) err := yaml.Unmarshal(kube.Out.Contents(), pod)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(pod.Spec).To(HaveField("HostNetwork", false)) Expect(pod.Spec).To(HaveField("HostNetwork", false))
Expect(pod.Spec.SecurityContext).To(BeNil()) Expect(pod.Spec.SecurityContext).To(BeNil())
Expect(pod.Spec.DNSConfig).To(BeNil()) Expect(pod.Spec.DNSConfig).To(BeNil())
@ -94,7 +94,7 @@ var _ = Describe("Podman generate kube", func() {
pod := new(v1.Pod) pod := new(v1.Pod)
err := yaml.Unmarshal(kube.Out.Contents(), pod) err := yaml.Unmarshal(kube.Out.Contents(), pod)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(kube.OutputToString()).To(ContainSubstring("level: s0:c100,c200")) Expect(kube.OutputToString()).To(ContainSubstring("level: s0:c100,c200"))
}) })
@ -109,7 +109,7 @@ var _ = Describe("Podman generate kube", func() {
pod := new(v1.Pod) pod := new(v1.Pod)
err = yaml.Unmarshal(kube.Out.Contents(), pod) err = yaml.Unmarshal(kube.Out.Contents(), pod)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(kube.OutputToString()).To(ContainSubstring("type: spc_t")) Expect(kube.OutputToString()).To(ContainSubstring("type: spc_t"))
}) })
@ -125,7 +125,7 @@ var _ = Describe("Podman generate kube", func() {
pod := new(v1.Pod) pod := new(v1.Pod)
err = yaml.Unmarshal(kube.Out.Contents(), pod) err = yaml.Unmarshal(kube.Out.Contents(), pod)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(kube.OutputToString()).To(ContainSubstring("type: foo_bar_t")) Expect(kube.OutputToString()).To(ContainSubstring("type: foo_bar_t"))
}) })
@ -144,13 +144,13 @@ var _ = Describe("Podman generate kube", func() {
svc := new(v1.Service) svc := new(v1.Service)
err := yaml.Unmarshal([]byte(arr[0]), svc) err := yaml.Unmarshal([]byte(arr[0]), svc)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(svc.Spec.Ports).To(HaveLen(1)) Expect(svc.Spec.Ports).To(HaveLen(1))
Expect(svc.Spec.Ports[0].TargetPort.IntValue()).To(Equal(3890)) Expect(svc.Spec.Ports[0].TargetPort.IntValue()).To(Equal(3890))
pod := new(v1.Pod) pod := new(v1.Pod)
err = yaml.Unmarshal([]byte(arr[1]), pod) err = yaml.Unmarshal([]byte(arr[1]), pod)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
}) })
It("podman generate kube on pod", func() { It("podman generate kube on pod", func() {
@ -167,7 +167,7 @@ var _ = Describe("Podman generate kube", func() {
pod := new(v1.Pod) pod := new(v1.Pod)
err := yaml.Unmarshal(kube.Out.Contents(), pod) err := yaml.Unmarshal(kube.Out.Contents(), pod)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(pod.Spec).To(HaveField("HostNetwork", false)) Expect(pod.Spec).To(HaveField("HostNetwork", false))
enableServiceLinks := false enableServiceLinks := false
Expect(pod.Spec).To(HaveField("EnableServiceLinks", &enableServiceLinks)) Expect(pod.Spec).To(HaveField("EnableServiceLinks", &enableServiceLinks))
@ -217,7 +217,7 @@ var _ = Describe("Podman generate kube", func() {
pod := new(v1.Pod) pod := new(v1.Pod)
err := yaml.Unmarshal(kube.Out.Contents(), pod) err := yaml.Unmarshal(kube.Out.Contents(), pod)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(pod.Spec).To(HaveField("HostNetwork", false)) Expect(pod.Spec).To(HaveField("HostNetwork", false))
numContainers := len(pod.Spec.Containers) + len(pod.Spec.InitContainers) numContainers := len(pod.Spec.Containers) + len(pod.Spec.InitContainers)
@ -238,7 +238,7 @@ var _ = Describe("Podman generate kube", func() {
pod = new(v1.Pod) pod = new(v1.Pod)
err = yaml.Unmarshal(kube.Out.Contents(), pod) err = yaml.Unmarshal(kube.Out.Contents(), pod)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(pod.Spec).To(HaveField("HostNetwork", false)) Expect(pod.Spec).To(HaveField("HostNetwork", false))
numContainers = len(pod.Spec.Containers) + len(pod.Spec.InitContainers) numContainers = len(pod.Spec.Containers) + len(pod.Spec.InitContainers)
@ -263,7 +263,7 @@ var _ = Describe("Podman generate kube", func() {
pod = new(v1.Pod) pod = new(v1.Pod)
err = yaml.Unmarshal(kube.Out.Contents(), pod) err = yaml.Unmarshal(kube.Out.Contents(), pod)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(pod.Spec).To(HaveField("HostNetwork", false)) Expect(pod.Spec).To(HaveField("HostNetwork", false))
numContainers = len(pod.Spec.Containers) + len(pod.Spec.InitContainers) numContainers = len(pod.Spec.Containers) + len(pod.Spec.InitContainers)
@ -272,7 +272,7 @@ var _ = Describe("Podman generate kube", func() {
It("podman generate kube on pod with user namespace", func() { It("podman generate kube on pod with user namespace", func() {
u, err := user.Current() u, err := user.Current()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
name := u.Name name := u.Name
if name == "root" { if name == "root" {
name = "containers" name = "containers"
@ -298,7 +298,7 @@ var _ = Describe("Podman generate kube", func() {
pod := new(v1.Pod) pod := new(v1.Pod)
err = yaml.Unmarshal(kube.Out.Contents(), pod) err = yaml.Unmarshal(kube.Out.Contents(), pod)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
expected := false expected := false
Expect(pod.Spec).To(HaveField("HostUsers", &expected)) Expect(pod.Spec).To(HaveField("HostUsers", &expected))
}) })
@ -318,7 +318,7 @@ var _ = Describe("Podman generate kube", func() {
pod := new(v1.Pod) pod := new(v1.Pod)
err := yaml.Unmarshal(kube.Out.Contents(), pod) err := yaml.Unmarshal(kube.Out.Contents(), pod)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(pod.Spec).To(HaveField("HostNetwork", true)) Expect(pod.Spec).To(HaveField("HostNetwork", true))
}) })
@ -333,7 +333,7 @@ var _ = Describe("Podman generate kube", func() {
pod := new(v1.Pod) pod := new(v1.Pod)
err := yaml.Unmarshal(kube.Out.Contents(), pod) err := yaml.Unmarshal(kube.Out.Contents(), pod)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(pod.Spec).To(HaveField("HostNetwork", true)) Expect(pod.Spec).To(HaveField("HostNetwork", true))
}) })
@ -363,7 +363,7 @@ var _ = Describe("Podman generate kube", func() {
pod := new(v1.Pod) pod := new(v1.Pod)
err := yaml.Unmarshal(kube.Out.Contents(), pod) err := yaml.Unmarshal(kube.Out.Contents(), pod)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(pod.Spec.HostAliases).To(HaveLen(2)) Expect(pod.Spec.HostAliases).To(HaveLen(2))
Expect(pod.Spec.HostAliases[0]).To(HaveField("IP", testIP)) Expect(pod.Spec.HostAliases[0]).To(HaveField("IP", testIP))
Expect(pod.Spec.HostAliases[1]).To(HaveField("IP", testIP)) Expect(pod.Spec.HostAliases[1]).To(HaveField("IP", testIP))
@ -402,7 +402,7 @@ var _ = Describe("Podman generate kube", func() {
pod := new(v1.Pod) pod := new(v1.Pod)
err := yaml.Unmarshal(kube.Out.Contents(), pod) err := yaml.Unmarshal(kube.Out.Contents(), pod)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(pod.Spec.Containers).To(HaveLen(2)) Expect(pod.Spec.Containers).To(HaveLen(2))
Expect(pod.Spec.Containers[0].Ports[0].ContainerPort).To(Equal(int32(8000))) Expect(pod.Spec.Containers[0].Ports[0].ContainerPort).To(Equal(int32(8000)))
Expect(pod.Spec.Containers[1].Ports[0].ContainerPort).To(Equal(int32(5000))) Expect(pod.Spec.Containers[1].Ports[0].ContainerPort).To(Equal(int32(5000)))
@ -445,7 +445,7 @@ var _ = Describe("Podman generate kube", func() {
pod := new(v1.Pod) pod := new(v1.Pod)
err := yaml.Unmarshal(kube.Out.Contents(), pod) err := yaml.Unmarshal(kube.Out.Contents(), pod)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(pod.Spec.Containers).To(HaveLen(2)) Expect(pod.Spec.Containers).To(HaveLen(2))
Expect(pod.Spec.Hostname).To(Equal(ctr1HostName)) Expect(pod.Spec.Hostname).To(Equal(ctr1HostName))
@ -467,7 +467,7 @@ var _ = Describe("Podman generate kube", func() {
pod = new(v1.Pod) pod = new(v1.Pod)
err = yaml.Unmarshal(kube.Out.Contents(), pod) err = yaml.Unmarshal(kube.Out.Contents(), pod)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(pod.Spec.Containers).To(HaveLen(1)) Expect(pod.Spec.Containers).To(HaveLen(1))
Expect(pod.Spec.Hostname).To(BeEmpty()) Expect(pod.Spec.Hostname).To(BeEmpty())
}) })
@ -487,14 +487,14 @@ var _ = Describe("Podman generate kube", func() {
svc := new(v1.Service) svc := new(v1.Service)
err := yaml.Unmarshal([]byte(arr[0]), svc) err := yaml.Unmarshal([]byte(arr[0]), svc)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(svc.Spec.Ports).To(HaveLen(1)) Expect(svc.Spec.Ports).To(HaveLen(1))
Expect(svc.Spec.Ports[0].TargetPort.IntValue()).To(Equal(4000)) Expect(svc.Spec.Ports[0].TargetPort.IntValue()).To(Equal(4000))
Expect(svc.Spec.Ports[0]).To(HaveField("Protocol", v1.ProtocolUDP)) Expect(svc.Spec.Ports[0]).To(HaveField("Protocol", v1.ProtocolUDP))
pod := new(v1.Pod) pod := new(v1.Pod)
err = yaml.Unmarshal([]byte(arr[1]), pod) err = yaml.Unmarshal([]byte(arr[1]), pod)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
}) })
It("podman generate kube on pod with restartPolicy", func() { It("podman generate kube on pod with restartPolicy", func() {
@ -524,7 +524,7 @@ var _ = Describe("Podman generate kube", func() {
pod := new(v1.Pod) pod := new(v1.Pod)
err := yaml.Unmarshal(kube.Out.Contents(), pod) err := yaml.Unmarshal(kube.Out.Contents(), pod)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(string(pod.Spec.RestartPolicy)).To(Equal(v[2])) Expect(string(pod.Spec.RestartPolicy)).To(Equal(v[2]))
} }
@ -548,7 +548,7 @@ var _ = Describe("Podman generate kube", func() {
pod := new(v1.Pod) pod := new(v1.Pod)
err := yaml.Unmarshal(kube.Out.Contents(), pod) err := yaml.Unmarshal(kube.Out.Contents(), pod)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
for _, ctr := range pod.Spec.Containers { for _, ctr := range pod.Spec.Containers {
memoryLimit, _ := ctr.Resources.Limits.Memory().AsInt64() memoryLimit, _ := ctr.Resources.Limits.Memory().AsInt64()
@ -581,7 +581,7 @@ var _ = Describe("Podman generate kube", func() {
pod := new(v1.Pod) pod := new(v1.Pod)
err := yaml.Unmarshal(kube.Out.Contents(), pod) err := yaml.Unmarshal(kube.Out.Contents(), pod)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
for _, ctr := range pod.Spec.Containers { for _, ctr := range pod.Spec.Containers {
cpuLimit := ctr.Resources.Limits.Cpu().MilliValue() cpuLimit := ctr.Resources.Limits.Cpu().MilliValue()
@ -616,7 +616,7 @@ var _ = Describe("Podman generate kube", func() {
pod := new(v1.Pod) pod := new(v1.Pod)
err := yaml.Unmarshal(kube.Out.Contents(), pod) err := yaml.Unmarshal(kube.Out.Contents(), pod)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
foundPort4000 := 0 foundPort4000 := 0
foundPort5000 := 0 foundPort5000 := 0
@ -651,7 +651,7 @@ var _ = Describe("Podman generate kube", func() {
pod = new(v1.Pod) pod = new(v1.Pod)
err = yaml.Unmarshal(kube.Out.Contents(), pod) err = yaml.Unmarshal(kube.Out.Contents(), pod)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
containers := pod.Spec.Containers containers := pod.Spec.Containers
Expect(containers).To(HaveLen(1)) Expect(containers).To(HaveLen(1))
@ -736,7 +736,7 @@ var _ = Describe("Podman generate kube", func() {
It("podman generate kube with volume", func() { It("podman generate kube with volume", func() {
vol1 := filepath.Join(podmanTest.TempDir, "vol-test1") vol1 := filepath.Join(podmanTest.TempDir, "vol-test1")
err := os.MkdirAll(vol1, 0755) err := os.MkdirAll(vol1, 0755)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// we need a container name because IDs don't persist after rm/play // we need a container name because IDs don't persist after rm/play
ctrName := "test-ctr" ctrName := "test-ctr"
@ -755,7 +755,7 @@ var _ = Describe("Podman generate kube", func() {
Expect(err).ShouldNot(HaveOccurred()) Expect(err).ShouldNot(HaveOccurred())
pod := new(v1.Pod) pod := new(v1.Pod)
err = yaml.Unmarshal(b, pod) err = yaml.Unmarshal(b, pod)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(pod.Annotations).To(HaveKeyWithValue(define.BindMountPrefix, vol1+":"+"z")) Expect(pod.Annotations).To(HaveKeyWithValue(define.BindMountPrefix, vol1+":"+"z"))
rm := podmanTest.Podman([]string{"pod", "rm", "-t", "0", "-f", "test1"}) rm := podmanTest.Podman([]string{"pod", "rm", "-t", "0", "-f", "test1"})
@ -789,7 +789,7 @@ var _ = Describe("Podman generate kube", func() {
pod := new(v1.Pod) pod := new(v1.Pod)
err := yaml.Unmarshal(kube.Out.Contents(), pod) err := yaml.Unmarshal(kube.Out.Contents(), pod)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(pod.Spec.Volumes).To(HaveLen(2)) Expect(pod.Spec.Volumes).To(HaveLen(2))
@ -921,11 +921,11 @@ var _ = Describe("Podman generate kube", func() {
pod := new(v1.Pod) pod := new(v1.Pod)
err := yaml.Unmarshal(kube.Out.Contents(), pod) err := yaml.Unmarshal(kube.Out.Contents(), pod)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(pod.Spec.DNSConfig.Nameservers).To(ContainElement("8.8.8.8")) Expect(pod.Spec.DNSConfig.Nameservers).To(ContainElement("8.8.8.8"))
Expect(pod.Spec.DNSConfig.Searches).To(ContainElement("foobar.com")) Expect(pod.Spec.DNSConfig.Searches).To(ContainElement("foobar.com"))
Expect(len(pod.Spec.DNSConfig.Options)).To(BeNumerically(">", 0)) Expect(pod.Spec.DNSConfig.Options).ToNot(BeEmpty())
Expect(pod.Spec.DNSConfig.Options[0]).To(HaveField("Name", "color")) Expect(pod.Spec.DNSConfig.Options[0]).To(HaveField("Name", "color"))
s := "blue" s := "blue"
Expect(pod.Spec.DNSConfig.Options[0]).To(HaveField("Value", &s)) Expect(pod.Spec.DNSConfig.Options[0]).To(HaveField("Value", &s))
@ -946,7 +946,7 @@ var _ = Describe("Podman generate kube", func() {
pod := new(v1.Pod) pod := new(v1.Pod)
err := yaml.Unmarshal(kube.Out.Contents(), pod) err := yaml.Unmarshal(kube.Out.Contents(), pod)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(pod.Spec.DNSConfig.Nameservers).To(ContainElement("8.8.8.8")) Expect(pod.Spec.DNSConfig.Nameservers).To(ContainElement("8.8.8.8"))
Expect(pod.Spec.DNSConfig.Nameservers).To(ContainElement("8.7.7.7")) Expect(pod.Spec.DNSConfig.Nameservers).To(ContainElement("8.7.7.7"))
@ -965,11 +965,11 @@ var _ = Describe("Podman generate kube", func() {
pod := new(v1.Pod) pod := new(v1.Pod)
err := yaml.Unmarshal(kube.Out.Contents(), pod) err := yaml.Unmarshal(kube.Out.Contents(), pod)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(pod.Spec.DNSConfig.Nameservers).To(ContainElement("8.8.8.8")) Expect(pod.Spec.DNSConfig.Nameservers).To(ContainElement("8.8.8.8"))
Expect(pod.Spec.DNSConfig.Searches).To(ContainElement("foobar.com")) Expect(pod.Spec.DNSConfig.Searches).To(ContainElement("foobar.com"))
Expect(len(pod.Spec.DNSConfig.Options)).To(BeNumerically(">", 0)) Expect(pod.Spec.DNSConfig.Options).ToNot(BeEmpty())
Expect(pod.Spec.DNSConfig.Options[0]).To(HaveField("Name", "color")) Expect(pod.Spec.DNSConfig.Options[0]).To(HaveField("Name", "color"))
s := "blue" s := "blue"
Expect(pod.Spec.DNSConfig.Options[0]).To(HaveField("Value", &s)) Expect(pod.Spec.DNSConfig.Options[0]).To(HaveField("Value", &s))
@ -988,7 +988,7 @@ var _ = Describe("Podman generate kube", func() {
// entrypoint and it's arguments to "10s". // entrypoint and it's arguments to "10s".
pod := new(v1.Pod) pod := new(v1.Pod)
err := yaml.Unmarshal(kube.Out.Contents(), pod) err := yaml.Unmarshal(kube.Out.Contents(), pod)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
containers := pod.Spec.Containers containers := pod.Spec.Containers
Expect(containers).To(HaveLen(1)) Expect(containers).To(HaveLen(1))
@ -1010,7 +1010,7 @@ var _ = Describe("Podman generate kube", func() {
// image command. // image command.
pod := new(v1.Pod) pod := new(v1.Pod)
err := yaml.Unmarshal(kube.Out.Contents(), pod) err := yaml.Unmarshal(kube.Out.Contents(), pod)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
containers := pod.Spec.Containers containers := pod.Spec.Containers
Expect(containers).To(HaveLen(1)) Expect(containers).To(HaveLen(1))
@ -1029,7 +1029,7 @@ var _ = Describe("Podman generate kube", func() {
// command passed via the cli to podman create. // command passed via the cli to podman create.
pod = new(v1.Pod) pod = new(v1.Pod)
err = yaml.Unmarshal(kube.Out.Contents(), pod) err = yaml.Unmarshal(kube.Out.Contents(), pod)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
containers = pod.Spec.Containers containers = pod.Spec.Containers
Expect(containers).To(HaveLen(1)) Expect(containers).To(HaveLen(1))
@ -1042,10 +1042,10 @@ var _ = Describe("Podman generate kube", func() {
ENTRYPOINT ["sleep"]` ENTRYPOINT ["sleep"]`
targetPath, err := CreateTempDirInTempDir() targetPath, err := CreateTempDirInTempDir()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
containerfilePath := filepath.Join(targetPath, "Containerfile") containerfilePath := filepath.Join(targetPath, "Containerfile")
err = os.WriteFile(containerfilePath, []byte(containerfile), 0644) err = os.WriteFile(containerfilePath, []byte(containerfile), 0644)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
image := "generatekube:test" image := "generatekube:test"
session := podmanTest.Podman([]string{"build", "--pull-never", "-f", containerfilePath, "-t", image}) session := podmanTest.Podman([]string{"build", "--pull-never", "-f", containerfilePath, "-t", image})
@ -1064,7 +1064,7 @@ ENTRYPOINT ["sleep"]`
// entrypoint but the arguments should be set to "10s". // entrypoint but the arguments should be set to "10s".
pod := new(v1.Pod) pod := new(v1.Pod)
err = yaml.Unmarshal(kube.Out.Contents(), pod) err = yaml.Unmarshal(kube.Out.Contents(), pod)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
containers := pod.Spec.Containers containers := pod.Spec.Containers
Expect(containers).To(HaveLen(1)) Expect(containers).To(HaveLen(1))
@ -1082,7 +1082,7 @@ ENTRYPOINT ["sleep"]`
// entrypoint defined by the --entrypoint flag and the arguments should be set to "hello". // entrypoint defined by the --entrypoint flag and the arguments should be set to "hello".
pod = new(v1.Pod) pod = new(v1.Pod)
err = yaml.Unmarshal(kube.Out.Contents(), pod) err = yaml.Unmarshal(kube.Out.Contents(), pod)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
containers = pod.Spec.Containers containers = pod.Spec.Containers
Expect(containers).To(HaveLen(1)) Expect(containers).To(HaveLen(1))
@ -1102,7 +1102,7 @@ ENTRYPOINT ["sleep"]`
// Now make sure that the capabilities aren't set. // Now make sure that the capabilities aren't set.
pod := new(v1.Pod) pod := new(v1.Pod)
err := yaml.Unmarshal(kube.Out.Contents(), pod) err := yaml.Unmarshal(kube.Out.Contents(), pod)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
containers := pod.Spec.Containers containers := pod.Spec.Containers
Expect(containers).To(HaveLen(1)) Expect(containers).To(HaveLen(1))
@ -1132,10 +1132,10 @@ RUN adduser -u 10001 -S test1
USER test1` USER test1`
targetPath, err := CreateTempDirInTempDir() targetPath, err := CreateTempDirInTempDir()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
containerfilePath := filepath.Join(targetPath, "Containerfile") containerfilePath := filepath.Join(targetPath, "Containerfile")
err = os.WriteFile(containerfilePath, []byte(containerfile), 0644) err = os.WriteFile(containerfilePath, []byte(containerfile), 0644)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
image := "generatekube:test" image := "generatekube:test"
session := podmanTest.Podman([]string{"build", "--pull-never", "-f", containerfilePath, "-t", image}) session := podmanTest.Podman([]string{"build", "--pull-never", "-f", containerfilePath, "-t", image})
@ -1152,7 +1152,7 @@ USER test1`
pod := new(v1.Pod) pod := new(v1.Pod)
err = yaml.Unmarshal(kube.Out.Contents(), pod) err = yaml.Unmarshal(kube.Out.Contents(), pod)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(pod.Spec.Containers[0].SecurityContext.RunAsUser).To(BeNil()) Expect(pod.Spec.Containers[0].SecurityContext.RunAsUser).To(BeNil())
}) })
@ -1169,7 +1169,7 @@ USER test1`
pvc := new(v1.PersistentVolumeClaim) pvc := new(v1.PersistentVolumeClaim)
err := yaml.Unmarshal(kube.Out.Contents(), pvc) err := yaml.Unmarshal(kube.Out.Contents(), pvc)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(pvc).To(HaveField("Name", vol)) Expect(pvc).To(HaveField("Name", vol))
Expect(pvc.Spec.AccessModes[0]).To(Equal(v1.ReadWriteOnce)) Expect(pvc.Spec.AccessModes[0]).To(Equal(v1.ReadWriteOnce))
Expect(pvc.Spec.Resources.Requests.Storage().String()).To(Equal("1Gi")) Expect(pvc.Spec.Resources.Requests.Storage().String()).To(Equal("1Gi"))
@ -1191,7 +1191,7 @@ USER test1`
pvc := new(v1.PersistentVolumeClaim) pvc := new(v1.PersistentVolumeClaim)
err := yaml.Unmarshal(kube.Out.Contents(), pvc) err := yaml.Unmarshal(kube.Out.Contents(), pvc)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(pvc).To(HaveField("Name", vol)) Expect(pvc).To(HaveField("Name", vol))
Expect(pvc.Spec.AccessModes[0]).To(Equal(v1.ReadWriteOnce)) Expect(pvc.Spec.AccessModes[0]).To(Equal(v1.ReadWriteOnce))
Expect(pvc.Spec.Resources.Requests.Storage().String()).To(Equal("1Gi")) Expect(pvc.Spec.Resources.Requests.Storage().String()).To(Equal("1Gi"))
@ -1219,7 +1219,7 @@ USER test1`
pod := new(v1.Pod) pod := new(v1.Pod)
err := yaml.Unmarshal(kube.Out.Contents(), pod) err := yaml.Unmarshal(kube.Out.Contents(), pod)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(pod.Annotations).To(HaveKeyWithValue("io.containers.autoupdate/top", "local")) Expect(pod.Annotations).To(HaveKeyWithValue("io.containers.autoupdate/top", "local"))
}) })
@ -1243,7 +1243,7 @@ USER test1`
pod := new(v1.Pod) pod := new(v1.Pod)
err := yaml.Unmarshal(kube.Out.Contents(), pod) err := yaml.Unmarshal(kube.Out.Contents(), pod)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(pod.Spec.Containers[0]).To(HaveField("WorkingDir", "")) Expect(pod.Spec.Containers[0]).To(HaveField("WorkingDir", ""))
Expect(pod.Spec.Containers[1]).To(HaveField("WorkingDir", "/root")) Expect(pod.Spec.Containers[1]).To(HaveField("WorkingDir", "/root"))
@ -1272,14 +1272,14 @@ USER test1`
pod := new(v1.Pod) pod := new(v1.Pod)
err := yaml.Unmarshal(kube.Out.Contents(), pod) err := yaml.Unmarshal(kube.Out.Contents(), pod)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(pod.Spec.Containers[0].Env).To(HaveLen(2)) Expect(pod.Spec.Containers[0].Env).To(HaveLen(2))
}) })
It("podman generate kube omit secret if empty", func() { It("podman generate kube omit secret if empty", func() {
dir, err := os.MkdirTemp(tempdir, "podman") dir, err := os.MkdirTemp(tempdir, "podman")
Expect(err).Should(BeNil()) Expect(err).ShouldNot(HaveOccurred())
defer os.RemoveAll(dir) defer os.RemoveAll(dir)
@ -1295,7 +1295,7 @@ USER test1`
pod := new(v1.Pod) pod := new(v1.Pod)
err = yaml.Unmarshal(kube.Out.Contents(), pod) err = yaml.Unmarshal(kube.Out.Contents(), pod)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(pod.Spec.Volumes[0].Secret).To(BeNil()) Expect(pod.Spec.Volumes[0].Secret).To(BeNil())
}) })

View File

@ -550,7 +550,7 @@ var _ = Describe("Podman generate systemd", func() {
It("podman generate systemd pod with containers --new", func() { It("podman generate systemd pod with containers --new", func() {
tmpDir, err := os.MkdirTemp("", "") tmpDir, err := os.MkdirTemp("", "")
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
tmpFile := tmpDir + "podID" tmpFile := tmpDir + "podID"
defer os.RemoveAll(tmpDir) defer os.RemoveAll(tmpDir)

View File

@ -293,24 +293,24 @@ var _ = Describe("Podman healthcheck run", func() {
It("Verify default time is used and no utf-8 escapes", func() { It("Verify default time is used and no utf-8 escapes", func() {
cwd, err := os.Getwd() cwd, err := os.Getwd()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
podmanTest.AddImageToRWStore(ALPINE) podmanTest.AddImageToRWStore(ALPINE)
// Write target and fake files // Write target and fake files
targetPath, err := CreateTempDirInTempDir() targetPath, err := CreateTempDirInTempDir()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
containerfile := fmt.Sprintf(`FROM %s containerfile := fmt.Sprintf(`FROM %s
HEALTHCHECK CMD ls -l / 2>&1`, ALPINE) HEALTHCHECK CMD ls -l / 2>&1`, ALPINE)
containerfilePath := filepath.Join(targetPath, "Containerfile") containerfilePath := filepath.Join(targetPath, "Containerfile")
err = os.WriteFile(containerfilePath, []byte(containerfile), 0644) err = os.WriteFile(containerfilePath, []byte(containerfile), 0644)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
defer func() { defer func() {
Expect(os.Chdir(cwd)).To(BeNil()) Expect(os.Chdir(cwd)).To(Succeed())
Expect(os.RemoveAll(targetPath)).To(BeNil()) Expect(os.RemoveAll(targetPath)).To(Succeed())
}() }()
// make cwd as context root path // make cwd as context root path
Expect(os.Chdir(targetPath)).To(BeNil()) Expect(os.Chdir(targetPath)).To(Succeed())
session := podmanTest.Podman([]string{"build", "--format", "docker", "-t", "test", "."}) session := podmanTest.Podman([]string{"build", "--format", "docker", "-t", "test", "."})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()

View File

@ -36,41 +36,41 @@ var _ = Describe("Podman history", func() {
session := podmanTest.Podman([]string{"history", ALPINE}) session := podmanTest.Podman([]string{"history", ALPINE})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0)) Expect(session).Should(Exit(0))
Expect(len(session.OutputToStringArray())).To(BeNumerically(">", 0)) Expect(session.OutputToStringArray()).ToNot(BeEmpty())
}) })
It("podman history with GO template", func() { It("podman history with GO template", func() {
session := podmanTest.Podman([]string{"history", "--format", "{{.ID}} {{.Created}}", ALPINE}) session := podmanTest.Podman([]string{"history", "--format", "{{.ID}} {{.Created}}", ALPINE})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0)) Expect(session).Should(Exit(0))
Expect(len(session.OutputToStringArray())).To(BeNumerically(">", 0)) Expect(session.OutputToStringArray()).ToNot(BeEmpty())
}) })
It("podman history with human flag", func() { It("podman history with human flag", func() {
session := podmanTest.Podman([]string{"history", "--human=false", ALPINE}) session := podmanTest.Podman([]string{"history", "--human=false", ALPINE})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0)) Expect(session).Should(Exit(0))
Expect(len(session.OutputToStringArray())).To(BeNumerically(">", 0)) Expect(session.OutputToStringArray()).ToNot(BeEmpty())
}) })
It("podman history with quiet flag", func() { It("podman history with quiet flag", func() {
session := podmanTest.Podman([]string{"history", "-qH", ALPINE}) session := podmanTest.Podman([]string{"history", "-qH", ALPINE})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0)) Expect(session).Should(Exit(0))
Expect(len(session.OutputToStringArray())).To(BeNumerically(">", 0)) Expect(session.OutputToStringArray()).ToNot(BeEmpty())
}) })
It("podman history with no-trunc flag", func() { It("podman history with no-trunc flag", func() {
session := podmanTest.Podman([]string{"history", "--no-trunc", ALPINE}) session := podmanTest.Podman([]string{"history", "--no-trunc", ALPINE})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0)) Expect(session).Should(Exit(0))
Expect(len(session.OutputToStringArray())).To(BeNumerically(">", 0)) Expect(session.OutputToStringArray()).ToNot(BeEmpty())
session = podmanTest.Podman([]string{"history", "--no-trunc", "--format", "{{.ID}}", ALPINE}) session = podmanTest.Podman([]string{"history", "--no-trunc", "--format", "{{.ID}}", ALPINE})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0)) Expect(session).Should(Exit(0))
lines := session.OutputToStringArray() lines := session.OutputToStringArray()
Expect(len(lines)).To(BeNumerically(">", 0)) Expect(lines).ToNot(BeEmpty())
// the image id must be 64 chars long // the image id must be 64 chars long
Expect(lines[0]).To(HaveLen(64)) Expect(lines[0]).To(HaveLen(64))
@ -78,7 +78,7 @@ var _ = Describe("Podman history", func() {
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0)) Expect(session).Should(Exit(0))
lines = session.OutputToStringArray() lines = session.OutputToStringArray()
Expect(len(lines)).To(BeNumerically(">", 0)) Expect(lines).ToNot(BeEmpty())
Expect(session.OutputToString()).ToNot(ContainSubstring("...")) Expect(session.OutputToString()).ToNot(ContainSubstring("..."))
// the second line in the alpine history contains a command longer than 45 chars // the second line in the alpine history contains a command longer than 45 chars
Expect(len(lines[1])).To(BeNumerically(">", 45)) Expect(len(lines[1])).To(BeNumerically(">", 45))

View File

@ -29,11 +29,11 @@ var _ = Describe("Podman image sign", func() {
podmanTest.Setup() podmanTest.Setup()
tempGNUPGHOME := filepath.Join(podmanTest.TempDir, "tmpGPG") tempGNUPGHOME := filepath.Join(podmanTest.TempDir, "tmpGPG")
err := os.Mkdir(tempGNUPGHOME, os.ModePerm) err := os.Mkdir(tempGNUPGHOME, os.ModePerm)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
origGNUPGHOME = os.Getenv("GNUPGHOME") origGNUPGHOME = os.Getenv("GNUPGHOME")
err = os.Setenv("GNUPGHOME", tempGNUPGHOME) err = os.Setenv("GNUPGHOME", tempGNUPGHOME)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
}) })
@ -47,29 +47,29 @@ var _ = Describe("Podman image sign", func() {
It("podman sign image", func() { It("podman sign image", func() {
cmd := exec.Command("gpg", "--import", "sign/secret-key.asc") cmd := exec.Command("gpg", "--import", "sign/secret-key.asc")
err := cmd.Run() err := cmd.Run()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
sigDir := filepath.Join(podmanTest.TempDir, "test-sign") sigDir := filepath.Join(podmanTest.TempDir, "test-sign")
err = os.MkdirAll(sigDir, os.ModePerm) err = os.MkdirAll(sigDir, os.ModePerm)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
session := podmanTest.Podman([]string{"image", "sign", "--directory", sigDir, "--sign-by", "foo@bar.com", "docker://library/alpine"}) session := podmanTest.Podman([]string{"image", "sign", "--directory", sigDir, "--sign-by", "foo@bar.com", "docker://library/alpine"})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0)) Expect(session).Should(Exit(0))
_, err = os.Stat(filepath.Join(sigDir, "library")) _, err = os.Stat(filepath.Join(sigDir, "library"))
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
}) })
It("podman sign --all multi-arch image", func() { It("podman sign --all multi-arch image", func() {
cmd := exec.Command("gpg", "--import", "sign/secret-key.asc") cmd := exec.Command("gpg", "--import", "sign/secret-key.asc")
err := cmd.Run() err := cmd.Run()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
sigDir := filepath.Join(podmanTest.TempDir, "test-sign-multi") sigDir := filepath.Join(podmanTest.TempDir, "test-sign-multi")
err = os.MkdirAll(sigDir, os.ModePerm) err = os.MkdirAll(sigDir, os.ModePerm)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
session := podmanTest.Podman([]string{"image", "sign", "--all", "--directory", sigDir, "--sign-by", "foo@bar.com", "docker://library/alpine"}) session := podmanTest.Podman([]string{"image", "sign", "--all", "--directory", sigDir, "--sign-by", "foo@bar.com", "docker://library/alpine"})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0)) Expect(session).Should(Exit(0))
fInfos, err := os.ReadDir(filepath.Join(sigDir, "library")) fInfos, err := os.ReadDir(filepath.Join(sigDir, "library"))
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(len(fInfos)).To(BeNumerically(">", 1), "len(fInfos)") Expect(len(fInfos)).To(BeNumerically(">", 1), "len(fInfos)")
}) })
}) })

View File

@ -171,7 +171,7 @@ RUN echo hello > /hello
result := podmanTest.Podman([]string{"images", "-q", "-f", "before=foobar.com/before:latest"}) result := podmanTest.Podman([]string{"images", "-q", "-f", "before=foobar.com/before:latest"})
result.WaitWithDefaultTimeout() result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0)) Expect(result).Should(Exit(0))
Expect(len(result.OutputToStringArray())).To(BeNumerically(">=", 1)) Expect(result.OutputToStringArray()).ToNot(BeEmpty())
}) })
It("podman images workingdir from image", func() { It("podman images workingdir from image", func() {

View File

@ -94,27 +94,27 @@ var _ = Describe("Podman Info", func() {
os.Unsetenv("CONTAINERS_STORAGE_CONF") os.Unsetenv("CONTAINERS_STORAGE_CONF")
}() }()
err := os.RemoveAll(filepath.Dir(configPath)) err := os.RemoveAll(filepath.Dir(configPath))
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
err = os.MkdirAll(filepath.Dir(configPath), os.ModePerm) err = os.MkdirAll(filepath.Dir(configPath), os.ModePerm)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
rootlessStoragePath := `"/tmp/$HOME/$USER/$UID/storage"` rootlessStoragePath := `"/tmp/$HOME/$USER/$UID/storage"`
driver := `"overlay"` driver := `"overlay"`
storageOpt := `"/usr/bin/fuse-overlayfs"` storageOpt := `"/usr/bin/fuse-overlayfs"`
storageConf := []byte(fmt.Sprintf("[storage]\ndriver=%s\nrootless_storage_path=%s\n[storage.options]\nmount_program=%s", driver, rootlessStoragePath, storageOpt)) storageConf := []byte(fmt.Sprintf("[storage]\ndriver=%s\nrootless_storage_path=%s\n[storage.options]\nmount_program=%s", driver, rootlessStoragePath, storageOpt))
err = os.WriteFile(configPath, storageConf, os.ModePerm) err = os.WriteFile(configPath, storageConf, os.ModePerm)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
u, err := user.Current() u, err := user.Current()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// Cannot use podmanTest.Podman() and test for storage path // Cannot use podmanTest.Podman() and test for storage path
expect := filepath.Join("/tmp", os.Getenv("HOME"), u.Username, u.Uid, "storage") expect := filepath.Join("/tmp", os.Getenv("HOME"), u.Username, u.Uid, "storage")
podmanPath := podmanTest.PodmanTest.PodmanBinary podmanPath := podmanTest.PodmanTest.PodmanBinary
cmd := exec.Command(podmanPath, "info", "--format", "{{.Store.GraphRoot -}}") cmd := exec.Command(podmanPath, "info", "--format", "{{.Store.GraphRoot -}}")
out, err := cmd.CombinedOutput() out, err := cmd.CombinedOutput()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(string(out)).To(Equal(expect)) Expect(string(out)).To(Equal(expect))
}) })

View File

@ -500,7 +500,7 @@ var _ = Describe("Podman inspect", func() {
data := inspect.InspectContainerToJSON() data := inspect.InspectContainerToJSON()
ulimits := data[0].HostConfig.Ulimits ulimits := data[0].HostConfig.Ulimits
Expect(len(ulimits)).To(BeNumerically(">", 0)) Expect(ulimits).ToNot(BeEmpty())
found := false found := false
for _, ulimit := range ulimits { for _, ulimit := range ulimits {
if ulimit.Name == "RLIMIT_CORE" { if ulimit.Name == "RLIMIT_CORE" {

View File

@ -150,7 +150,7 @@ var _ = Describe("Podman kill", func() {
It("podman kill --cidfile", func() { It("podman kill --cidfile", func() {
tmpDir, err := os.MkdirTemp("", "") tmpDir, err := os.MkdirTemp("", "")
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
tmpFile := tmpDir + "cid" tmpFile := tmpDir + "cid"
defer os.RemoveAll(tmpDir) defer os.RemoveAll(tmpDir)
@ -170,12 +170,12 @@ var _ = Describe("Podman kill", func() {
It("podman kill multiple --cidfile", func() { It("podman kill multiple --cidfile", func() {
tmpDir1, err := os.MkdirTemp("", "") tmpDir1, err := os.MkdirTemp("", "")
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
tmpFile1 := tmpDir1 + "cid" tmpFile1 := tmpDir1 + "cid"
defer os.RemoveAll(tmpDir1) defer os.RemoveAll(tmpDir1)
tmpDir2, err := os.MkdirTemp("", "") tmpDir2, err := os.MkdirTemp("", "")
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
tmpFile2 := tmpDir2 + "cid" tmpFile2 := tmpDir2 + "cid"
defer os.RemoveAll(tmpDir2) defer os.RemoveAll(tmpDir2)

View File

@ -101,11 +101,11 @@ var _ = Describe("Podman login and logout", func() {
readAuthInfo := func(filePath string) map[string]interface{} { readAuthInfo := func(filePath string) map[string]interface{} {
authBytes, err := os.ReadFile(filePath) authBytes, err := os.ReadFile(filePath)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
var authInfo map[string]interface{} var authInfo map[string]interface{}
err = json.Unmarshal(authBytes, &authInfo) err = json.Unmarshal(authBytes, &authInfo)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
fmt.Println(authInfo) fmt.Println(authInfo)
const authsKey = "auths" const authsKey = "auths"
@ -137,12 +137,12 @@ var _ = Describe("Podman login and logout", func() {
It("podman login and logout without registry parameter", func() { It("podman login and logout without registry parameter", func() {
registriesConf, err := os.CreateTemp("", "TestLoginWithoutParameter") registriesConf, err := os.CreateTemp("", "TestLoginWithoutParameter")
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
defer registriesConf.Close() defer registriesConf.Close()
defer os.Remove(registriesConf.Name()) defer os.Remove(registriesConf.Name())
err = os.WriteFile(registriesConf.Name(), registriesConfWithSearch, os.ModePerm) err = os.WriteFile(registriesConf.Name(), registriesConfWithSearch, os.ModePerm)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// Environment is per-process, so this looks very unsafe; actually it seems fine because tests are not // Environment is per-process, so this looks very unsafe; actually it seems fine because tests are not
// run in parallel unless they opt in by calling t.Parallel(). So dont do that. // run in parallel unless they opt in by calling t.Parallel(). So dont do that.
@ -451,7 +451,7 @@ var _ = Describe("Podman login and logout", func() {
"%s/podmantest": { "auth": "cG9kbWFudGVzdDp3cm9uZw==" }, "%s/podmantest": { "auth": "cG9kbWFudGVzdDp3cm9uZw==" },
"%s": { "auth": "cG9kbWFudGVzdDp0ZXN0" } "%s": { "auth": "cG9kbWFudGVzdDp0ZXN0" }
}}`, server, server)), 0644) }}`, server, server)), 0644)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
session := podmanTest.Podman([]string{ session := podmanTest.Podman([]string{
"push", "push",
@ -498,7 +498,7 @@ var _ = Describe("Podman login and logout", func() {
"%s/podmantest": { "auth": "cG9kbWFudGVzdDp0ZXN0" }, "%s/podmantest": { "auth": "cG9kbWFudGVzdDp0ZXN0" },
"%s": { "auth": "cG9kbWFudGVzdDp0ZXN0" } "%s": { "auth": "cG9kbWFudGVzdDp0ZXN0" }
}}`, server, server, server)), 0644) }}`, server, server, server)), 0644)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
session = podmanTest.Podman([]string{ session = podmanTest.Podman([]string{
"pull", "pull",

View File

@ -482,7 +482,7 @@ var _ = Describe("Podman logs", func() {
cmd := exec.Command("journalctl", "--no-pager", "-o", "json", "--output-fields=CONTAINER_TAG", fmt.Sprintf("CONTAINER_ID_FULL=%s", cid)) cmd := exec.Command("journalctl", "--no-pager", "-o", "json", "--output-fields=CONTAINER_TAG", fmt.Sprintf("CONTAINER_ID_FULL=%s", cid))
out, err := cmd.CombinedOutput() out, err := cmd.CombinedOutput()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(string(out)).To(ContainSubstring("alpine")) Expect(string(out)).To(ContainSubstring("alpine"))
}) })
@ -500,7 +500,7 @@ var _ = Describe("Podman logs", func() {
cmd := exec.Command("journalctl", "--no-pager", "-o", "json", "--output-fields=CONTAINER_NAME", fmt.Sprintf("CONTAINER_ID_FULL=%s", cid)) cmd := exec.Command("journalctl", "--no-pager", "-o", "json", "--output-fields=CONTAINER_NAME", fmt.Sprintf("CONTAINER_ID_FULL=%s", cid))
out, err := cmd.CombinedOutput() out, err := cmd.CombinedOutput()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(string(out)).To(ContainSubstring(containerName)) Expect(string(out)).To(ContainSubstring(containerName))
}) })

View File

@ -184,7 +184,7 @@ var _ = Describe("Podman manifest", func() {
var inspect libimage.ManifestListData var inspect libimage.ManifestListData
err := json.Unmarshal(session.Out.Contents(), &inspect) err := json.Unmarshal(session.Out.Contents(), &inspect)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(inspect.Manifests[0].Annotations).To(Equal(map[string]string{"hoge": "fuga"})) Expect(inspect.Manifests[0].Annotations).To(Equal(map[string]string{"hoge": "fuga"}))
}) })
@ -274,7 +274,7 @@ var _ = Describe("Podman manifest", func() {
Expect(session).Should(Exit(0)) Expect(session).Should(Exit(0))
dest := filepath.Join(podmanTest.TempDir, "pushed") dest := filepath.Join(podmanTest.TempDir, "pushed")
err := os.MkdirAll(dest, os.ModePerm) err := os.MkdirAll(dest, os.ModePerm)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
defer func() { defer func() {
os.RemoveAll(dest) os.RemoveAll(dest)
}() }()
@ -308,7 +308,7 @@ var _ = Describe("Podman manifest", func() {
Expect(session).Should(Exit(0)) Expect(session).Should(Exit(0))
dest := filepath.Join(podmanTest.TempDir, "pushed") dest := filepath.Join(podmanTest.TempDir, "pushed")
err := os.MkdirAll(dest, os.ModePerm) err := os.MkdirAll(dest, os.ModePerm)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
defer func() { defer func() {
os.RemoveAll(dest) os.RemoveAll(dest)
}() }()
@ -316,7 +316,7 @@ var _ = Describe("Podman manifest", func() {
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0)) Expect(session).Should(Exit(0))
files, err := filepath.Glob(dest + string(os.PathSeparator) + "*") files, err := filepath.Glob(dest + string(os.PathSeparator) + "*")
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
check := SystemExec("sha256sum", files) check := SystemExec("sha256sum", files)
check.WaitWithDefaultTimeout() check.WaitWithDefaultTimeout()
Expect(check).Should(Exit(0)) Expect(check).Should(Exit(0))
@ -342,7 +342,7 @@ var _ = Describe("Podman manifest", func() {
Expect(session).Should(Exit(0)) Expect(session).Should(Exit(0))
dest := filepath.Join(podmanTest.TempDir, "pushed") dest := filepath.Join(podmanTest.TempDir, "pushed")
err := os.MkdirAll(dest, os.ModePerm) err := os.MkdirAll(dest, os.ModePerm)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
defer func() { defer func() {
os.RemoveAll(dest) os.RemoveAll(dest)
}() }()
@ -355,13 +355,13 @@ var _ = Describe("Podman manifest", func() {
blobsDir := filepath.Join(dest, "blobs", "sha256") blobsDir := filepath.Join(dest, "blobs", "sha256")
blobs, err := os.ReadDir(blobsDir) blobs, err := os.ReadDir(blobsDir)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
for _, f := range blobs { for _, f := range blobs {
blobPath := filepath.Join(blobsDir, f.Name()) blobPath := filepath.Join(blobsDir, f.Name())
sourceFile, err := os.ReadFile(blobPath) sourceFile, err := os.ReadFile(blobPath)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
compressionType := archive.DetectCompression(sourceFile) compressionType := archive.DetectCompression(sourceFile)
if compressionType == archive.Zstd { if compressionType == archive.Zstd {
@ -381,7 +381,7 @@ var _ = Describe("Podman manifest", func() {
dest := filepath.Join(podmanTest.TempDir, "pushed") dest := filepath.Join(podmanTest.TempDir, "pushed")
err := os.MkdirAll(dest, os.ModePerm) err := os.MkdirAll(dest, os.ModePerm)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
defer func() { defer func() {
os.RemoveAll(dest) os.RemoveAll(dest)
}() }()
@ -412,10 +412,10 @@ var _ = Describe("Podman manifest", func() {
} }
os.Setenv("PODMAN", podmanTest.PodmanBinary+" "+opts) os.Setenv("PODMAN", podmanTest.PodmanBinary+" "+opts)
registry, err := podmanRegistry.StartWithOptions(registryOptions) registry, err := podmanRegistry.StartWithOptions(registryOptions)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
defer func() { defer func() {
err := registry.Stop() err := registry.Stop()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
os.Unsetenv("PODMAN") os.Unsetenv("PODMAN")
}() }()
@ -480,7 +480,7 @@ var _ = Describe("Podman manifest", func() {
Expect(session).Should(Exit(0)) Expect(session).Should(Exit(0))
dest := filepath.Join(podmanTest.TempDir, "pushed") dest := filepath.Join(podmanTest.TempDir, "pushed")
err := os.MkdirAll(dest, os.ModePerm) err := os.MkdirAll(dest, os.ModePerm)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
defer func() { defer func() {
os.RemoveAll(dest) os.RemoveAll(dest)
}() }()

View File

@ -55,7 +55,7 @@ var _ = Describe("Podman network create", func() {
// JSON the network configuration into something usable // JSON the network configuration into something usable
var results []types.Network var results []types.Network
err := json.Unmarshal([]byte(inspect.OutputToString()), &results) err := json.Unmarshal([]byte(inspect.OutputToString()), &results)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(results).To(HaveLen(1)) Expect(results).To(HaveLen(1))
result := results[0] result := results[0]
Expect(result).To(HaveField("Name", netName)) Expect(result).To(HaveField("Name", netName))
@ -75,10 +75,10 @@ var _ = Describe("Podman network create", func() {
Expect(try).To(Exit(0)) Expect(try).To(Exit(0))
_, subnet, err := net.ParseCIDR("10.11.12.0/24") _, subnet, err := net.ParseCIDR("10.11.12.0/24")
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// Note this is an IPv4 test only! // Note this is an IPv4 test only!
containerIP, _, err := net.ParseCIDR(try.OutputToString()) containerIP, _, err := net.ParseCIDR(try.OutputToString())
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// Ensure that the IP the container got is within the subnet the user asked for // Ensure that the IP the container got is within the subnet the user asked for
Expect(subnet.Contains(containerIP)).To(BeTrue()) Expect(subnet.Contains(containerIP)).To(BeTrue())
}) })
@ -98,7 +98,7 @@ var _ = Describe("Podman network create", func() {
// JSON the network configuration into something usable // JSON the network configuration into something usable
var results []types.Network var results []types.Network
err := json.Unmarshal([]byte(inspect.OutputToString()), &results) err := json.Unmarshal([]byte(inspect.OutputToString()), &results)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(results).To(HaveLen(1)) Expect(results).To(HaveLen(1))
result := results[0] result := results[0]
Expect(result).To(HaveField("Name", netName)) Expect(result).To(HaveField("Name", netName))
@ -115,9 +115,9 @@ var _ = Describe("Podman network create", func() {
Expect(try).To(Exit(0)) Expect(try).To(Exit(0))
_, subnet, err := net.ParseCIDR("fd00:1:2:3:4::/64") _, subnet, err := net.ParseCIDR("fd00:1:2:3:4::/64")
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
containerIP, _, err := net.ParseCIDR(try.OutputToString()) containerIP, _, err := net.ParseCIDR(try.OutputToString())
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// Ensure that the IP the container got is within the subnet the user asked for // Ensure that the IP the container got is within the subnet the user asked for
Expect(subnet.Contains(containerIP)).To(BeTrue()) Expect(subnet.Contains(containerIP)).To(BeTrue())
}) })
@ -137,7 +137,7 @@ var _ = Describe("Podman network create", func() {
// JSON the network configuration into something usable // JSON the network configuration into something usable
var results []types.Network var results []types.Network
err := json.Unmarshal([]byte(inspect.OutputToString()), &results) err := json.Unmarshal([]byte(inspect.OutputToString()), &results)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(results).To(HaveLen(1)) Expect(results).To(HaveLen(1))
result := results[0] result := results[0]
Expect(result).To(HaveField("Name", netName)) Expect(result).To(HaveField("Name", netName))
@ -146,9 +146,9 @@ var _ = Describe("Podman network create", func() {
Expect(result.Subnets[1].Subnet.IP).ToNot(BeNil()) Expect(result.Subnets[1].Subnet.IP).ToNot(BeNil())
_, subnet11, err := net.ParseCIDR(result.Subnets[0].Subnet.String()) _, subnet11, err := net.ParseCIDR(result.Subnets[0].Subnet.String())
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
_, subnet12, err := net.ParseCIDR(result.Subnets[1].Subnet.String()) _, subnet12, err := net.ParseCIDR(result.Subnets[1].Subnet.String())
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// Once a container executes a new network, the nic will be created. We should clean those up // Once a container executes a new network, the nic will be created. We should clean those up
// best we can // best we can
@ -169,7 +169,7 @@ var _ = Describe("Podman network create", func() {
// JSON the network configuration into something usable // JSON the network configuration into something usable
err = json.Unmarshal([]byte(inspect.OutputToString()), &results) err = json.Unmarshal([]byte(inspect.OutputToString()), &results)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(results).To(HaveLen(1)) Expect(results).To(HaveLen(1))
result = results[0] result = results[0]
Expect(result).To(HaveField("Name", netName2)) Expect(result).To(HaveField("Name", netName2))
@ -178,9 +178,9 @@ var _ = Describe("Podman network create", func() {
Expect(result.Subnets[1].Subnet.IP).ToNot(BeNil()) Expect(result.Subnets[1].Subnet.IP).ToNot(BeNil())
_, subnet21, err := net.ParseCIDR(result.Subnets[0].Subnet.String()) _, subnet21, err := net.ParseCIDR(result.Subnets[0].Subnet.String())
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
_, subnet22, err := net.ParseCIDR(result.Subnets[1].Subnet.String()) _, subnet22, err := net.ParseCIDR(result.Subnets[1].Subnet.String())
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// check that the subnets do not overlap // check that the subnets do not overlap
Expect(subnet11.Contains(subnet21.IP)).To(BeFalse()) Expect(subnet11.Contains(subnet21.IP)).To(BeFalse())
@ -190,16 +190,16 @@ var _ = Describe("Podman network create", func() {
try.WaitWithDefaultTimeout() try.WaitWithDefaultTimeout()
_, subnet, err := net.ParseCIDR("fd00:4:3:2:1::/64") _, subnet, err := net.ParseCIDR("fd00:4:3:2:1::/64")
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
containerIP, _, err := net.ParseCIDR(try.OutputToString()) containerIP, _, err := net.ParseCIDR(try.OutputToString())
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// Ensure that the IP the container got is within the subnet the user asked for // Ensure that the IP the container got is within the subnet the user asked for
Expect(subnet.Contains(containerIP)).To(BeTrue()) Expect(subnet.Contains(containerIP)).To(BeTrue())
// verify the container has an IPv4 address too (the IPv4 subnet is autogenerated) // verify the container has an IPv4 address too (the IPv4 subnet is autogenerated)
try = podmanTest.Podman([]string{"run", "-it", "--rm", "--network", netName, ALPINE, "sh", "-c", "ip addr show eth0 | awk ' /inet / {print $2}'"}) try = podmanTest.Podman([]string{"run", "-it", "--rm", "--network", netName, ALPINE, "sh", "-c", "ip addr show eth0 | awk ' /inet / {print $2}'"})
try.WaitWithDefaultTimeout() try.WaitWithDefaultTimeout()
containerIP, _, err = net.ParseCIDR(try.OutputToString()) containerIP, _, err = net.ParseCIDR(try.OutputToString())
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(containerIP.To4()).To(Not(BeNil())) Expect(containerIP.To4()).To(Not(BeNil()))
}) })

View File

@ -618,7 +618,7 @@ var _ = Describe("Podman network", func() {
// JSON the network configuration into something usable // JSON the network configuration into something usable
var results []types.Network var results []types.Network
err := json.Unmarshal([]byte(inspect.OutputToString()), &results) err := json.Unmarshal([]byte(inspect.OutputToString()), &results)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(results).To(HaveLen(1)) Expect(results).To(HaveLen(1))
result := results[0] result := results[0]
Expect(result).To(HaveField("NetworkInterface", "")) Expect(result).To(HaveField("NetworkInterface", ""))
@ -644,7 +644,7 @@ var _ = Describe("Podman network", func() {
var results []types.Network var results []types.Network
err := json.Unmarshal([]byte(inspect.OutputToString()), &results) err := json.Unmarshal([]byte(inspect.OutputToString()), &results)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(results).To(HaveLen(1)) Expect(results).To(HaveLen(1))
result := results[0] result := results[0]
@ -687,7 +687,7 @@ var _ = Describe("Podman network", func() {
var results []types.Network var results []types.Network
err := json.Unmarshal([]byte(inspect.OutputToString()), &results) err := json.Unmarshal([]byte(inspect.OutputToString()), &results)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(results).To(HaveLen(1)) Expect(results).To(HaveLen(1))
result := results[0] result := results[0]

View File

@ -336,7 +336,7 @@ var _ = Describe("Podman pause", func() {
It("podman pause --cidfile", func() { It("podman pause --cidfile", func() {
tmpDir, err := os.MkdirTemp("", "") tmpDir, err := os.MkdirTemp("", "")
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
tmpFile := tmpDir + "cid" tmpFile := tmpDir + "cid"
defer os.RemoveAll(tmpDir) defer os.RemoveAll(tmpDir)
@ -365,7 +365,7 @@ var _ = Describe("Podman pause", func() {
It("podman pause multiple --cidfile", func() { It("podman pause multiple --cidfile", func() {
tmpDir, err := os.MkdirTemp("", "") tmpDir, err := os.MkdirTemp("", "")
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
tmpFile1 := tmpDir + "cid-1" tmpFile1 := tmpDir + "cid-1"
tmpFile2 := tmpDir + "cid-2" tmpFile2 := tmpDir + "cid-2"

View File

@ -93,21 +93,21 @@ LABEL marge=mom
// Setup // Setup
yamlDir := filepath.Join(tempdir, RandomString(12)) yamlDir := filepath.Join(tempdir, RandomString(12))
err := os.Mkdir(yamlDir, 0755) err := os.Mkdir(yamlDir, 0755)
Expect(err).To(BeNil(), "mkdir "+yamlDir) Expect(err).ToNot(HaveOccurred(), "mkdir "+yamlDir)
err = writeYaml(testYAML, filepath.Join(yamlDir, "top.yaml")) err = writeYaml(testYAML, filepath.Join(yamlDir, "top.yaml"))
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
app1Dir := filepath.Join(yamlDir, "foobar") app1Dir := filepath.Join(yamlDir, "foobar")
err = os.Mkdir(app1Dir, 0755) err = os.Mkdir(app1Dir, 0755)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
err = writeYaml(playBuildFile, filepath.Join(app1Dir, "Dockerfile")) err = writeYaml(playBuildFile, filepath.Join(app1Dir, "Dockerfile"))
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// Write a file to be copied // Write a file to be copied
err = writeYaml(copyFile, filepath.Join(app1Dir, "copyfile")) err = writeYaml(copyFile, filepath.Join(app1Dir, "copyfile"))
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// Switch to temp dir and restore it afterwards // Switch to temp dir and restore it afterwards
cwd, err := os.Getwd() cwd, err := os.Getwd()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(os.Chdir(yamlDir)).To(BeNil()) Expect(os.Chdir(yamlDir)).To(Succeed())
defer func() { (Expect(os.Chdir(cwd)).To(BeNil())) }() defer func() { (Expect(os.Chdir(cwd)).To(BeNil())) }()
session := podmanTest.Podman([]string{"play", "kube", "top.yaml"}) session := podmanTest.Podman([]string{"play", "kube", "top.yaml"})
@ -122,7 +122,7 @@ LABEL marge=mom
inspect.WaitWithDefaultTimeout() inspect.WaitWithDefaultTimeout()
Expect(inspect).Should(Exit(0)) Expect(inspect).Should(Exit(0))
inspectData := inspect.InspectContainerToJSON() inspectData := inspect.InspectContainerToJSON()
Expect(len(inspectData)).To(BeNumerically(">", 0)) Expect(inspectData).ToNot(BeEmpty())
Expect(inspectData[0].Config.Labels).To(HaveKeyWithValue("homer", "dad")) Expect(inspectData[0].Config.Labels).To(HaveKeyWithValue("homer", "dad"))
}) })
@ -130,21 +130,21 @@ LABEL marge=mom
// Setup // Setup
yamlDir := filepath.Join(tempdir, RandomString(12)) yamlDir := filepath.Join(tempdir, RandomString(12))
err := os.Mkdir(yamlDir, 0755) err := os.Mkdir(yamlDir, 0755)
Expect(err).To(BeNil(), "mkdir "+yamlDir) Expect(err).ToNot(HaveOccurred(), "mkdir "+yamlDir)
err = writeYaml(testYAML, filepath.Join(yamlDir, "top.yaml")) err = writeYaml(testYAML, filepath.Join(yamlDir, "top.yaml"))
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
app1Dir := filepath.Join(yamlDir, "foobar") app1Dir := filepath.Join(yamlDir, "foobar")
err = os.Mkdir(app1Dir, 0755) err = os.Mkdir(app1Dir, 0755)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
err = writeYaml(playBuildFile, filepath.Join(app1Dir, "Containerfile")) err = writeYaml(playBuildFile, filepath.Join(app1Dir, "Containerfile"))
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// Write a file to be copied // Write a file to be copied
err = writeYaml(copyFile, filepath.Join(app1Dir, "copyfile")) err = writeYaml(copyFile, filepath.Join(app1Dir, "copyfile"))
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// Switch to temp dir and restore it afterwards // Switch to temp dir and restore it afterwards
cwd, err := os.Getwd() cwd, err := os.Getwd()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(os.Chdir(yamlDir)).To(BeNil()) Expect(os.Chdir(yamlDir)).To(Succeed())
defer func() { (Expect(os.Chdir(cwd)).To(BeNil())) }() defer func() { (Expect(os.Chdir(cwd)).To(BeNil())) }()
session := podmanTest.Podman([]string{"play", "kube", "top.yaml"}) session := podmanTest.Podman([]string{"play", "kube", "top.yaml"})
@ -159,7 +159,7 @@ LABEL marge=mom
inspect.WaitWithDefaultTimeout() inspect.WaitWithDefaultTimeout()
Expect(inspect).Should(Exit(0)) Expect(inspect).Should(Exit(0))
inspectData := inspect.InspectContainerToJSON() inspectData := inspect.InspectContainerToJSON()
Expect(len(inspectData)).To(BeNumerically(">", 0)) Expect(inspectData).ToNot(BeEmpty())
Expect(inspectData[0].Config.Labels).To(HaveKeyWithValue("homer", "dad")) Expect(inspectData[0].Config.Labels).To(HaveKeyWithValue("homer", "dad"))
}) })
@ -167,29 +167,29 @@ LABEL marge=mom
// Setup // Setup
yamlDir := filepath.Join(tempdir, RandomString(12)) yamlDir := filepath.Join(tempdir, RandomString(12))
err := os.Mkdir(yamlDir, 0755) err := os.Mkdir(yamlDir, 0755)
Expect(err).To(BeNil(), "mkdir "+yamlDir) Expect(err).ToNot(HaveOccurred(), "mkdir "+yamlDir)
err = writeYaml(testYAML, filepath.Join(yamlDir, "top.yaml")) err = writeYaml(testYAML, filepath.Join(yamlDir, "top.yaml"))
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// build an image called foobar but make sure it doesn't have // build an image called foobar but make sure it doesn't have
// the same label as the yaml buildfile, so we can check that // the same label as the yaml buildfile, so we can check that
// the image is NOT rebuilt. // the image is NOT rebuilt.
err = writeYaml(prebuiltImage, filepath.Join(yamlDir, "Containerfile")) err = writeYaml(prebuiltImage, filepath.Join(yamlDir, "Containerfile"))
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
app1Dir := filepath.Join(yamlDir, "foobar") app1Dir := filepath.Join(yamlDir, "foobar")
err = os.Mkdir(app1Dir, 0755) err = os.Mkdir(app1Dir, 0755)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
err = writeYaml(playBuildFile, filepath.Join(app1Dir, "Containerfile")) err = writeYaml(playBuildFile, filepath.Join(app1Dir, "Containerfile"))
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// Write a file to be copied // Write a file to be copied
err = writeYaml(copyFile, filepath.Join(app1Dir, "copyfile")) err = writeYaml(copyFile, filepath.Join(app1Dir, "copyfile"))
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// Switch to temp dir and restore it afterwards // Switch to temp dir and restore it afterwards
cwd, err := os.Getwd() cwd, err := os.Getwd()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(os.Chdir(yamlDir)).To(BeNil()) Expect(os.Chdir(yamlDir)).To(Succeed())
defer func() { (Expect(os.Chdir(cwd)).To(BeNil())) }() defer func() { (Expect(os.Chdir(cwd)).To(BeNil())) }()
// Build the image into the local store // Build the image into the local store
@ -205,7 +205,7 @@ LABEL marge=mom
inspect.WaitWithDefaultTimeout() inspect.WaitWithDefaultTimeout()
Expect(inspect).Should(Exit(0)) Expect(inspect).Should(Exit(0))
inspectData := inspect.InspectContainerToJSON() inspectData := inspect.InspectContainerToJSON()
Expect(len(inspectData)).To(BeNumerically(">", 0)) Expect(inspectData).ToNot(BeEmpty())
Expect(inspectData[0].Config.Labels).To(Not(HaveKey("homer"))) Expect(inspectData[0].Config.Labels).To(Not(HaveKey("homer")))
Expect(inspectData[0].Config.Labels).To(HaveKeyWithValue("marge", "mom")) Expect(inspectData[0].Config.Labels).To(HaveKeyWithValue("marge", "mom"))
}) })
@ -214,29 +214,29 @@ LABEL marge=mom
// Setup // Setup
yamlDir := filepath.Join(tempdir, RandomString(12)) yamlDir := filepath.Join(tempdir, RandomString(12))
err := os.Mkdir(yamlDir, 0755) err := os.Mkdir(yamlDir, 0755)
Expect(err).To(BeNil(), "mkdir "+yamlDir) Expect(err).ToNot(HaveOccurred(), "mkdir "+yamlDir)
err = writeYaml(testYAML, filepath.Join(yamlDir, "top.yaml")) err = writeYaml(testYAML, filepath.Join(yamlDir, "top.yaml"))
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// build an image called foobar but make sure it doesn't have // build an image called foobar but make sure it doesn't have
// the same label as the yaml buildfile, so we can check that // the same label as the yaml buildfile, so we can check that
// the image is NOT rebuilt. // the image is NOT rebuilt.
err = writeYaml(prebuiltImage, filepath.Join(yamlDir, "Containerfile")) err = writeYaml(prebuiltImage, filepath.Join(yamlDir, "Containerfile"))
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
app1Dir := filepath.Join(yamlDir, "foobar") app1Dir := filepath.Join(yamlDir, "foobar")
err = os.Mkdir(app1Dir, 0755) err = os.Mkdir(app1Dir, 0755)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
err = writeYaml(playBuildFile, filepath.Join(app1Dir, "Containerfile")) err = writeYaml(playBuildFile, filepath.Join(app1Dir, "Containerfile"))
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// Write a file to be copied // Write a file to be copied
err = writeYaml(copyFile, filepath.Join(app1Dir, "copyfile")) err = writeYaml(copyFile, filepath.Join(app1Dir, "copyfile"))
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// Switch to temp dir and restore it afterwards // Switch to temp dir and restore it afterwards
cwd, err := os.Getwd() cwd, err := os.Getwd()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(os.Chdir(yamlDir)).To(BeNil()) Expect(os.Chdir(yamlDir)).To(Succeed())
defer func() { (Expect(os.Chdir(cwd)).To(BeNil())) }() defer func() { (Expect(os.Chdir(cwd)).To(BeNil())) }()
// Build the image into the local store // Build the image into the local store
@ -252,7 +252,7 @@ LABEL marge=mom
inspect.WaitWithDefaultTimeout() inspect.WaitWithDefaultTimeout()
Expect(inspect).Should(Exit(0)) Expect(inspect).Should(Exit(0))
inspectData := inspect.InspectContainerToJSON() inspectData := inspect.InspectContainerToJSON()
Expect(len(inspectData)).To(BeNumerically(">", 0)) Expect(inspectData).ToNot(BeEmpty())
Expect(inspectData[0].Config.Labels).To(Not(HaveKey("homer"))) Expect(inspectData[0].Config.Labels).To(Not(HaveKey("homer")))
Expect(inspectData[0].Config.Labels).To(HaveKeyWithValue("marge", "mom")) Expect(inspectData[0].Config.Labels).To(HaveKeyWithValue("marge", "mom"))
}) })
@ -261,29 +261,29 @@ LABEL marge=mom
// Setup // Setup
yamlDir := filepath.Join(tempdir, RandomString(12)) yamlDir := filepath.Join(tempdir, RandomString(12))
err := os.Mkdir(yamlDir, 0755) err := os.Mkdir(yamlDir, 0755)
Expect(err).To(BeNil(), "os.Mkdir "+yamlDir) Expect(err).ToNot(HaveOccurred(), "os.Mkdir "+yamlDir)
err = writeYaml(testYAML, filepath.Join(yamlDir, "top.yaml")) err = writeYaml(testYAML, filepath.Join(yamlDir, "top.yaml"))
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// build an image called foobar but make sure it doesn't have // build an image called foobar but make sure it doesn't have
// the same label as the yaml buildfile, so we can check that // the same label as the yaml buildfile, so we can check that
// the image is NOT rebuilt. // the image is NOT rebuilt.
err = writeYaml(prebuiltImage, filepath.Join(yamlDir, "Containerfile")) err = writeYaml(prebuiltImage, filepath.Join(yamlDir, "Containerfile"))
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
app1Dir := filepath.Join(yamlDir, "foobar") app1Dir := filepath.Join(yamlDir, "foobar")
err = os.Mkdir(app1Dir, 0755) err = os.Mkdir(app1Dir, 0755)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
err = writeYaml(playBuildFile, filepath.Join(app1Dir, "Containerfile")) err = writeYaml(playBuildFile, filepath.Join(app1Dir, "Containerfile"))
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// Write a file to be copied // Write a file to be copied
err = writeYaml(copyFile, filepath.Join(app1Dir, "copyfile")) err = writeYaml(copyFile, filepath.Join(app1Dir, "copyfile"))
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// Switch to temp dir and restore it afterwards // Switch to temp dir and restore it afterwards
cwd, err := os.Getwd() cwd, err := os.Getwd()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(os.Chdir(yamlDir)).To(BeNil()) Expect(os.Chdir(yamlDir)).To(Succeed())
defer func() { (Expect(os.Chdir(cwd)).To(BeNil())) }() defer func() { (Expect(os.Chdir(cwd)).To(BeNil())) }()
// Build the image into the local store // Build the image into the local store
@ -299,7 +299,7 @@ LABEL marge=mom
inspect.WaitWithDefaultTimeout() inspect.WaitWithDefaultTimeout()
Expect(inspect).Should(Exit(0)) Expect(inspect).Should(Exit(0))
inspectData := inspect.InspectContainerToJSON() inspectData := inspect.InspectContainerToJSON()
Expect(len(inspectData)).To(BeNumerically(">", 0)) Expect(inspectData).ToNot(BeEmpty())
Expect(inspectData[0].Config.Labels).To(HaveKeyWithValue("homer", "dad")) Expect(inspectData[0].Config.Labels).To(HaveKeyWithValue("homer", "dad"))
Expect(inspectData[0].Config.Labels).To(Not(HaveKey("marge"))) Expect(inspectData[0].Config.Labels).To(Not(HaveKey("marge")))
}) })

File diff suppressed because it is too large Load Diff

View File

@ -317,8 +317,8 @@ var _ = Describe("Podman pod create", func() {
It("podman create pod and print id to external file", func() { It("podman create pod and print id to external file", func() {
// Switch to temp dir and restore it afterwards // Switch to temp dir and restore it afterwards
cwd, err := os.Getwd() cwd, err := os.Getwd()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(os.Chdir(os.TempDir())).To(BeNil()) Expect(os.Chdir(os.TempDir())).To(Succeed())
targetPath, err := CreateTempDirInTempDir() targetPath, err := CreateTempDirInTempDir()
if err != nil { if err != nil {
os.Exit(1) os.Exit(1)
@ -682,7 +682,7 @@ ENTRYPOINT ["sleep","99999"]
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0)) Expect(session).Should(Exit(0))
u, err := user.Current() u, err := user.Current()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(session.OutputToString()).To(ContainSubstring(u.Name)) Expect(session.OutputToString()).To(ContainSubstring(u.Name))
// root owns /usr // root owns /usr
@ -731,7 +731,7 @@ ENTRYPOINT ["sleep","99999"]
It("podman pod create with --userns=auto", func() { It("podman pod create with --userns=auto", func() {
u, err := user.Current() u, err := user.Current()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
name := u.Name name := u.Name
if name == "root" { if name == "root" {
name = "containers" name = "containers"
@ -765,7 +765,7 @@ ENTRYPOINT ["sleep","99999"]
It("podman pod create --userns=auto:size=%d", func() { It("podman pod create --userns=auto:size=%d", func() {
u, err := user.Current() u, err := user.Current()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
name := u.Name name := u.Name
if name == "root" { if name == "root" {
@ -801,7 +801,7 @@ ENTRYPOINT ["sleep","99999"]
It("podman pod create --userns=auto:uidmapping=", func() { It("podman pod create --userns=auto:uidmapping=", func() {
u, err := user.Current() u, err := user.Current()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
name := u.Name name := u.Name
if name == "root" { if name == "root" {
@ -838,7 +838,7 @@ ENTRYPOINT ["sleep","99999"]
It("podman pod create --userns=auto:gidmapping=", func() { It("podman pod create --userns=auto:gidmapping=", func() {
u, err := user.Current() u, err := user.Current()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
name := u.Name name := u.Name
if name == "root" { if name == "root" {
@ -912,7 +912,7 @@ ENTRYPOINT ["sleep","99999"]
It("podman pod create --device", func() { It("podman pod create --device", func() {
SkipIfRootless("Cannot create devices in /dev in rootless mode") SkipIfRootless("Cannot create devices in /dev in rootless mode")
Expect(os.MkdirAll("/dev/foodevdir", os.ModePerm)).To(BeNil()) Expect(os.MkdirAll("/dev/foodevdir", os.ModePerm)).To(Succeed())
defer os.RemoveAll("/dev/foodevdir") defer os.RemoveAll("/dev/foodevdir")
mknod := SystemExec("mknod", []string{"/dev/foodevdir/null", "c", "1", "3"}) mknod := SystemExec("mknod", []string{"/dev/foodevdir/null", "c", "1", "3"})

View File

@ -366,7 +366,7 @@ var _ = Describe("Podman pod create", func() {
result = podmanTest.Podman([]string{"ps", "-aq"}) result = podmanTest.Podman([]string{"ps", "-aq"})
result.WaitWithDefaultTimeout() result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0)) Expect(result).Should(Exit(0))
Expect(len(result.OutputToStringArray())).Should(BeNumerically(">", 0)) Expect(result.OutputToStringArray()).ShouldNot(BeEmpty())
Expect(result.OutputToString()).To(ContainSubstring(infraID)) Expect(result.OutputToString()).To(ContainSubstring(infraID))
}) })
@ -394,7 +394,7 @@ var _ = Describe("Podman pod create", func() {
result = podmanTest.Podman([]string{"ps", "-aq"}) result = podmanTest.Podman([]string{"ps", "-aq"})
result.WaitWithDefaultTimeout() result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0)) Expect(result).Should(Exit(0))
Expect(len(result.OutputToStringArray())).Should(BeNumerically(">", 0)) Expect(result.OutputToStringArray()).ShouldNot(BeEmpty())
Expect(result.OutputToString()).To(ContainSubstring(infraID)) Expect(result.OutputToString()).To(ContainSubstring(infraID))
}) })

View File

@ -94,7 +94,7 @@ var _ = Describe("Podman pod inspect", func() {
inspectJSON := new(define.InspectPodData) inspectJSON := new(define.InspectPodData)
err := json.Unmarshal(inspectOut.Out.Contents(), inspectJSON) err := json.Unmarshal(inspectOut.Out.Contents(), inspectJSON)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(inspectJSON.InfraConfig).To(Not(BeNil())) Expect(inspectJSON.InfraConfig).To(Not(BeNil()))
Expect(inspectJSON.InfraConfig.PortBindings["80/tcp"]).To(HaveLen(1)) Expect(inspectJSON.InfraConfig.PortBindings["80/tcp"]).To(HaveLen(1))
Expect(inspectJSON.InfraConfig.PortBindings["80/tcp"][0]).To(HaveField("HostPort", "8383")) Expect(inspectJSON.InfraConfig.PortBindings["80/tcp"][0]).To(HaveField("HostPort", "8383"))

View File

@ -52,7 +52,7 @@ var _ = Describe("Podman ps", func() {
result := podmanTest.Podman([]string{"pod", "ps"}) result := podmanTest.Podman([]string{"pod", "ps"})
result.WaitWithDefaultTimeout() result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0)) Expect(result).Should(Exit(0))
Expect(len(result.OutputToStringArray())).Should(BeNumerically(">", 0)) Expect(result.OutputToStringArray()).ShouldNot(BeEmpty())
}) })
It("podman pod ps quiet flag", func() { It("podman pod ps quiet flag", func() {
@ -65,7 +65,7 @@ var _ = Describe("Podman ps", func() {
result := podmanTest.Podman([]string{"pod", "ps", "-q"}) result := podmanTest.Podman([]string{"pod", "ps", "-q"})
result.WaitWithDefaultTimeout() result.WaitWithDefaultTimeout()
Expect(result).To(Exit(0)) Expect(result).To(Exit(0))
Expect(len(result.OutputToStringArray())).Should(BeNumerically(">", 0)) Expect(result.OutputToStringArray()).ShouldNot(BeEmpty())
Expect(podid).To(ContainSubstring(result.OutputToStringArray()[0])) Expect(podid).To(ContainSubstring(result.OutputToStringArray()[0]))
}) })
@ -79,7 +79,7 @@ var _ = Describe("Podman ps", func() {
result := podmanTest.Podman([]string{"pod", "ps", "-q", "--no-trunc"}) result := podmanTest.Podman([]string{"pod", "ps", "-q", "--no-trunc"})
result.WaitWithDefaultTimeout() result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0)) Expect(result).Should(Exit(0))
Expect(len(result.OutputToStringArray())).Should(BeNumerically(">", 0)) Expect(result.OutputToStringArray()).ShouldNot(BeEmpty())
Expect(podid).To(Equal(result.OutputToStringArray()[0])) Expect(podid).To(Equal(result.OutputToStringArray()[0]))
}) })

View File

@ -50,14 +50,14 @@ var _ = Describe("Podman pod rm", func() {
return err return err
} }
if !d.IsDir() { if !d.IsDir() {
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
} }
if strings.Contains(d.Name(), podid) { if strings.Contains(d.Name(), podid) {
return fmt.Errorf("leaking cgroup path %s", path) return fmt.Errorf("leaking cgroup path %s", path)
} }
return nil return nil
}) })
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
}) })
It("podman pod rm latest pod", func() { It("podman pod rm latest pod", func() {
@ -142,7 +142,7 @@ var _ = Describe("Podman pod rm", func() {
result.WaitWithDefaultTimeout() result.WaitWithDefaultTimeout()
Expect(result).To(ExitWithError()) Expect(result).To(ExitWithError())
foundExpectedError, _ := result.ErrorGrepString("cannot be removed") foundExpectedError, _ := result.ErrorGrepString("cannot be removed")
Expect(foundExpectedError).To(Equal(true)) Expect(foundExpectedError).To(BeTrue())
numPods = podmanTest.NumberOfPods() numPods = podmanTest.NumberOfPods()
ps = podmanTest.Podman([]string{"pod", "ps"}) ps = podmanTest.Podman([]string{"pod", "ps"})
@ -235,7 +235,7 @@ var _ = Describe("Podman pod rm", func() {
It("podman pod start/remove single pod via --pod-id-file", func() { It("podman pod start/remove single pod via --pod-id-file", func() {
tmpDir, err := os.MkdirTemp("", "") tmpDir, err := os.MkdirTemp("", "")
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
tmpFile := tmpDir + "podID" tmpFile := tmpDir + "podID"
defer os.RemoveAll(tmpDir) defer os.RemoveAll(tmpDir)
@ -264,7 +264,7 @@ var _ = Describe("Podman pod rm", func() {
It("podman pod start/remove multiple pods via --pod-id-file", func() { It("podman pod start/remove multiple pods via --pod-id-file", func() {
tmpDir, err := os.MkdirTemp("", "") tmpDir, err := os.MkdirTemp("", "")
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
defer os.RemoveAll(tmpDir) defer os.RemoveAll(tmpDir)
podIDFiles := []string{} podIDFiles := []string{}

View File

@ -175,7 +175,7 @@ var _ = Describe("Podman pod start", func() {
It("podman pod start single pod via --pod-id-file", func() { It("podman pod start single pod via --pod-id-file", func() {
tmpDir, err := os.MkdirTemp("", "") tmpDir, err := os.MkdirTemp("", "")
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
tmpFile := tmpDir + "podID" tmpFile := tmpDir + "podID"
defer os.RemoveAll(tmpDir) defer os.RemoveAll(tmpDir)
@ -199,7 +199,7 @@ var _ = Describe("Podman pod start", func() {
It("podman pod start multiple pods via --pod-id-file", func() { It("podman pod start multiple pods via --pod-id-file", func() {
tmpDir, err := os.MkdirTemp("", "") tmpDir, err := os.MkdirTemp("", "")
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
defer os.RemoveAll(tmpDir) defer os.RemoveAll(tmpDir)
podIDFiles := []string{} podIDFiles := []string{}
@ -231,7 +231,7 @@ var _ = Describe("Podman pod start", func() {
It("podman pod create --infra-conmon-pod create + start", func() { It("podman pod create --infra-conmon-pod create + start", func() {
tmpDir, err := os.MkdirTemp("", "") tmpDir, err := os.MkdirTemp("", "")
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
tmpFile := tmpDir + "podID" tmpFile := tmpDir + "podID"
defer os.RemoveAll(tmpDir) defer os.RemoveAll(tmpDir)
@ -248,7 +248,7 @@ var _ = Describe("Podman pod start", func() {
readFirstLine := func(path string) string { readFirstLine := func(path string) string {
content, err := os.ReadFile(path) content, err := os.ReadFile(path)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
return strings.Split(string(content), "\n")[0] return strings.Split(string(content), "\n")[0]
} }
@ -256,7 +256,7 @@ var _ = Describe("Podman pod start", func() {
// on the pid. // on the pid.
infraConmonPID := readFirstLine(tmpFile) infraConmonPID := readFirstLine(tmpFile)
_, err = strconv.Atoi(infraConmonPID) // Make sure it's a proper integer _, err = strconv.Atoi(infraConmonPID) // Make sure it's a proper integer
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
cmdline := readFirstLine(fmt.Sprintf("/proc/%s/cmdline", infraConmonPID)) cmdline := readFirstLine(fmt.Sprintf("/proc/%s/cmdline", infraConmonPID))
Expect(cmdline).To(ContainSubstring("/conmon")) Expect(cmdline).To(ContainSubstring("/conmon"))

View File

@ -181,7 +181,7 @@ var _ = Describe("Podman pod stop", func() {
It("podman pod start/stop single pod via --pod-id-file", func() { It("podman pod start/stop single pod via --pod-id-file", func() {
tmpDir, err := os.MkdirTemp("", "") tmpDir, err := os.MkdirTemp("", "")
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
tmpFile := tmpDir + "podID" tmpFile := tmpDir + "podID"
defer os.RemoveAll(tmpDir) defer os.RemoveAll(tmpDir)
@ -210,7 +210,7 @@ var _ = Describe("Podman pod stop", func() {
It("podman pod start/stop multiple pods via --pod-id-file", func() { It("podman pod start/stop multiple pods via --pod-id-file", func() {
tmpDir, err := os.MkdirTemp("", "") tmpDir, err := os.MkdirTemp("", "")
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
defer os.RemoveAll(tmpDir) defer os.RemoveAll(tmpDir)
podIDFiles := []string{} podIDFiles := []string{}

View File

@ -190,7 +190,7 @@ var _ = Describe("Podman prune", func() {
hasNoneAfter, result := after.GrepString("<none>") hasNoneAfter, result := after.GrepString("<none>")
Expect(hasNoneAfter).To(BeTrue()) Expect(hasNoneAfter).To(BeTrue())
Expect(len(after.OutputToStringArray())).To(BeNumerically(">", 1)) Expect(len(after.OutputToStringArray())).To(BeNumerically(">", 1))
Expect(len(result)).To(BeNumerically(">", 0)) Expect(result).ToNot(BeEmpty())
}) })
It("podman image prune unused images", func() { It("podman image prune unused images", func() {

View File

@ -58,7 +58,7 @@ var _ = Describe("Podman ps", func() {
result := podmanTest.Podman([]string{"ps"}) result := podmanTest.Podman([]string{"ps"})
result.WaitWithDefaultTimeout() result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0)) Expect(result).Should(Exit(0))
Expect(len(result.OutputToStringArray())).Should(BeNumerically(">", 0)) Expect(result.OutputToStringArray()).ShouldNot(BeEmpty())
}) })
It("podman ps all", func() { It("podman ps all", func() {
@ -68,7 +68,7 @@ var _ = Describe("Podman ps", func() {
result := podmanTest.Podman([]string{"ps", "-a"}) result := podmanTest.Podman([]string{"ps", "-a"})
result.WaitWithDefaultTimeout() result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0)) Expect(result).Should(Exit(0))
Expect(len(result.OutputToStringArray())).Should(BeNumerically(">", 0)) Expect(result.OutputToStringArray()).ShouldNot(BeEmpty())
}) })
It("podman container list all", func() { It("podman container list all", func() {
@ -78,12 +78,12 @@ var _ = Describe("Podman ps", func() {
result := podmanTest.Podman([]string{"container", "list", "-a"}) result := podmanTest.Podman([]string{"container", "list", "-a"})
result.WaitWithDefaultTimeout() result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0)) Expect(result).Should(Exit(0))
Expect(len(result.OutputToStringArray())).Should(BeNumerically(">", 0)) Expect(result.OutputToStringArray()).ShouldNot(BeEmpty())
result = podmanTest.Podman([]string{"container", "ls", "-a"}) result = podmanTest.Podman([]string{"container", "ls", "-a"})
result.WaitWithDefaultTimeout() result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0)) Expect(result).Should(Exit(0))
Expect(len(result.OutputToStringArray())).Should(BeNumerically(">", 0)) Expect(result.OutputToStringArray()).ShouldNot(BeEmpty())
}) })
It("podman ps size flag", func() { It("podman ps size flag", func() {
@ -93,7 +93,7 @@ var _ = Describe("Podman ps", func() {
result := podmanTest.Podman([]string{"ps", "-a", "--size"}) result := podmanTest.Podman([]string{"ps", "-a", "--size"})
result.WaitWithDefaultTimeout() result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0)) Expect(result).Should(Exit(0))
Expect(len(result.OutputToStringArray())).Should(BeNumerically(">", 0)) Expect(result.OutputToStringArray()).ShouldNot(BeEmpty())
}) })
It("podman ps quiet flag", func() { It("podman ps quiet flag", func() {
@ -103,7 +103,7 @@ var _ = Describe("Podman ps", func() {
result := podmanTest.Podman([]string{"ps", "-a", "-q"}) result := podmanTest.Podman([]string{"ps", "-a", "-q"})
result.WaitWithDefaultTimeout() result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0)) Expect(result).Should(Exit(0))
Expect(len(result.OutputToStringArray())).Should(BeNumerically(">", 0)) Expect(result.OutputToStringArray()).ShouldNot(BeEmpty())
Expect(fullCid).To(ContainSubstring(result.OutputToStringArray()[0])) Expect(fullCid).To(ContainSubstring(result.OutputToStringArray()[0]))
}) })
@ -166,7 +166,7 @@ var _ = Describe("Podman ps", func() {
result := podmanTest.Podman([]string{"ps", "-aq", "--no-trunc"}) result := podmanTest.Podman([]string{"ps", "-aq", "--no-trunc"})
result.WaitWithDefaultTimeout() result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0)) Expect(result).Should(Exit(0))
Expect(len(result.OutputToStringArray())).Should(BeNumerically(">", 0)) Expect(result.OutputToStringArray()).ShouldNot(BeEmpty())
Expect(fullCid).To(Equal(result.OutputToStringArray()[0])) Expect(fullCid).To(Equal(result.OutputToStringArray()[0]))
}) })
@ -219,7 +219,7 @@ var _ = Describe("Podman ps", func() {
result := podmanTest.Podman([]string{"ps", "-a", "--namespace"}) result := podmanTest.Podman([]string{"ps", "-a", "--namespace"})
result.WaitWithDefaultTimeout() result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0)) Expect(result).Should(Exit(0))
Expect(len(result.OutputToStringArray())).Should(BeNumerically(">", 0)) Expect(result.OutputToStringArray()).ShouldNot(BeEmpty())
}) })
It("podman ps namespace flag even for remote", func() { It("podman ps namespace flag even for remote", func() {
@ -264,9 +264,9 @@ var _ = Describe("Podman ps", func() {
// Make sure Created field is an int64 // Make sure Created field is an int64
created, err := result.jq(".[0].Created") created, err := result.jq(".[0].Created")
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
_, err = strconv.ParseInt(created, 10, 64) _, err = strconv.ParseInt(created, 10, 64)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
}) })
It("podman ps print a human-readable `Status` with json format", func() { It("podman ps print a human-readable `Status` with json format", func() {

View File

@ -45,7 +45,7 @@ var _ = Describe("Podman pull", func() {
Expect(session).Should(Exit(125)) Expect(session).Should(Exit(125))
expectedError := "initializing source docker://ibetthisdoesnotexistfr:random" expectedError := "initializing source docker://ibetthisdoesnotexistfr:random"
found, _ := session.ErrorGrepString(expectedError) found, _ := session.ErrorGrepString(expectedError)
Expect(found).To(Equal(true)) Expect(found).To(BeTrue())
session = podmanTest.Podman([]string{"rmi", "busybox:musl", "alpine", "quay.io/libpod/cirros", "testdigest_v2s2@sha256:755f4d90b3716e2bf57060d249e2cd61c9ac089b1233465c5c2cb2d7ee550fdb"}) session = podmanTest.Podman([]string{"rmi", "busybox:musl", "alpine", "quay.io/libpod/cirros", "testdigest_v2s2@sha256:755f4d90b3716e2bf57060d249e2cd61c9ac089b1233465c5c2cb2d7ee550fdb"})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
@ -289,7 +289,7 @@ var _ = Describe("Podman pull", func() {
Expect(session).Should(Exit(125)) Expect(session).Should(Exit(125))
expectedError := "Unexpected tar manifest.json: expected 1 item, got 2" expectedError := "Unexpected tar manifest.json: expected 1 item, got 2"
found, _ := session.ErrorGrepString(expectedError) found, _ := session.ErrorGrepString(expectedError)
Expect(found).To(Equal(true)) Expect(found).To(BeTrue())
// Now pull _one_ image from a multi-image archive via the name // Now pull _one_ image from a multi-image archive via the name
// and index syntax. // and index syntax.
@ -315,14 +315,14 @@ var _ = Describe("Podman pull", func() {
Expect(session).Should(Exit(125)) Expect(session).Should(Exit(125))
expectedError = "Tag \"foo.com/does/not/exist:latest\" not found" expectedError = "Tag \"foo.com/does/not/exist:latest\" not found"
found, _ = session.ErrorGrepString(expectedError) found, _ = session.ErrorGrepString(expectedError)
Expect(found).To(Equal(true)) Expect(found).To(BeTrue())
session = podmanTest.Podman([]string{"pull", "docker-archive:./testdata/docker-two-images.tar.xz:@2"}) session = podmanTest.Podman([]string{"pull", "docker-archive:./testdata/docker-two-images.tar.xz:@2"})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(125)) Expect(session).Should(Exit(125))
expectedError = "Invalid source index @2, only 2 manifest items available" expectedError = "Invalid source index @2, only 2 manifest items available"
found, _ = session.ErrorGrepString(expectedError) found, _ = session.ErrorGrepString(expectedError)
Expect(found).To(Equal(true)) Expect(found).To(BeTrue())
}) })
It("podman pull from oci-archive", func() { It("podman pull from oci-archive", func() {

View File

@ -78,13 +78,13 @@ var _ = Describe("Podman push", func() {
blobsDir := filepath.Join(bbdir, "blobs/sha256") blobsDir := filepath.Join(bbdir, "blobs/sha256")
blobs, err := os.ReadDir(blobsDir) blobs, err := os.ReadDir(blobsDir)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
for _, f := range blobs { for _, f := range blobs {
blobPath := filepath.Join(blobsDir, f.Name()) blobPath := filepath.Join(blobsDir, f.Name())
sourceFile, err := os.ReadFile(blobPath) sourceFile, err := os.ReadFile(blobPath)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
compressionType := archive.DetectCompression(sourceFile) compressionType := archive.DetectCompression(sourceFile)
if compressionType == archive.Zstd { if compressionType == archive.Zstd {
@ -116,7 +116,7 @@ var _ = Describe("Podman push", func() {
push := podmanTest.Podman([]string{"push", "-q", "--tls-verify=false", "--remove-signatures", ALPINE, "localhost:5000/my-alpine"}) push := podmanTest.Podman([]string{"push", "-q", "--tls-verify=false", "--remove-signatures", ALPINE, "localhost:5000/my-alpine"})
push.WaitWithDefaultTimeout() push.WaitWithDefaultTimeout()
Expect(push).Should(Exit(0)) Expect(push).Should(Exit(0))
Expect(len(push.ErrorToString())).To(Equal(0)) Expect(push.ErrorToString()).To(BeEmpty())
push = podmanTest.Podman([]string{"push", "--tls-verify=false", "--remove-signatures", ALPINE, "localhost:5000/my-alpine"}) push = podmanTest.Podman([]string{"push", "--tls-verify=false", "--remove-signatures", ALPINE, "localhost:5000/my-alpine"})
push.WaitWithDefaultTimeout() push.WaitWithDefaultTimeout()
@ -132,7 +132,7 @@ var _ = Describe("Podman push", func() {
push2 := podmanTest.Podman([]string{"push", "--tls-verify=false", "--digestfile=/tmp/digestfile.txt", "--remove-signatures", ALPINE, "localhost:5000/my-alpine"}) push2 := podmanTest.Podman([]string{"push", "--tls-verify=false", "--digestfile=/tmp/digestfile.txt", "--remove-signatures", ALPINE, "localhost:5000/my-alpine"})
push2.WaitWithDefaultTimeout() push2.WaitWithDefaultTimeout()
fi, err := os.Lstat("/tmp/digestfile.txt") fi, err := os.Lstat("/tmp/digestfile.txt")
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(fi.Name()).To(Equal("digestfile.txt")) Expect(fi.Name()).To(Equal("digestfile.txt"))
Expect(push2).Should(Exit(0)) Expect(push2).Should(Exit(0))
} }
@ -157,7 +157,7 @@ var _ = Describe("Podman push", func() {
push := podmanTest.Podman([]string{"push", "-q", "--tls-verify=false", "--remove-signatures", ALPINE, "localhost:5000/sigstore-signed"}) push := podmanTest.Podman([]string{"push", "-q", "--tls-verify=false", "--remove-signatures", ALPINE, "localhost:5000/sigstore-signed"})
push.WaitWithDefaultTimeout() push.WaitWithDefaultTimeout()
Expect(push).Should(Exit(0)) Expect(push).Should(Exit(0))
Expect(len(push.ErrorToString())).To(Equal(0)) Expect(push.ErrorToString()).To(BeEmpty())
pull := podmanTest.Podman([]string{"pull", "-q", "--tls-verify=false", "--signature-policy", "sign/policy.json", "localhost:5000/sigstore-signed"}) pull := podmanTest.Podman([]string{"pull", "-q", "--tls-verify=false", "--signature-policy", "sign/policy.json", "localhost:5000/sigstore-signed"})
pull.WaitWithDefaultTimeout() pull.WaitWithDefaultTimeout()
@ -168,7 +168,7 @@ var _ = Describe("Podman push", func() {
push = podmanTest.Podman([]string{"push", "-q", "--tls-verify=false", "--remove-signatures", "--sign-by-sigstore-private-key", "testdata/sigstore-key.key", "--sign-passphrase-file", "testdata/sigstore-key.key.pass", ALPINE, "localhost:5000/sigstore-signed"}) push = podmanTest.Podman([]string{"push", "-q", "--tls-verify=false", "--remove-signatures", "--sign-by-sigstore-private-key", "testdata/sigstore-key.key", "--sign-passphrase-file", "testdata/sigstore-key.key.pass", ALPINE, "localhost:5000/sigstore-signed"})
push.WaitWithDefaultTimeout() push.WaitWithDefaultTimeout()
Expect(push).Should(Exit(0)) Expect(push).Should(Exit(0))
Expect(len(push.ErrorToString())).To(Equal(0)) Expect(push.ErrorToString()).To(BeEmpty())
pull = podmanTest.Podman([]string{"pull", "-q", "--tls-verify=false", "--signature-policy", "sign/policy.json", "localhost:5000/sigstore-signed"}) pull = podmanTest.Podman([]string{"pull", "-q", "--tls-verify=false", "--signature-policy", "sign/policy.json", "localhost:5000/sigstore-signed"})
pull.WaitWithDefaultTimeout() pull.WaitWithDefaultTimeout()

View File

@ -24,7 +24,7 @@ type quadletTestcase struct {
func loadQuadletTestcase(path string) *quadletTestcase { func loadQuadletTestcase(path string) *quadletTestcase {
data, err := os.ReadFile(path) data, err := os.ReadFile(path)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
base := filepath.Base(path) base := filepath.Base(path)
ext := filepath.Ext(base) ext := filepath.Ext(base)
@ -39,7 +39,7 @@ func loadQuadletTestcase(path string) *quadletTestcase {
for _, line := range strings.Split(string(data), "\n") { for _, line := range strings.Split(string(data), "\n") {
if strings.HasPrefix(line, "##") { if strings.HasPrefix(line, "##") {
words, err := shellwords.Parse(line[2:]) words, err := shellwords.Parse(line[2:])
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
checks = append(checks, words) checks = append(checks, words)
} }
} }
@ -222,7 +222,7 @@ func (t *quadletTestcase) check(generateDir string, session *PodmanSessionIntegr
var unit *parser.UnitFile var unit *parser.UnitFile
if !expectFail { if !expectFail {
unit, err = parser.ParseUnitFile(file) unit, err = parser.ParseUnitFile(file)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
} }
for _, check := range t.checks { for _, check := range t.checks {
@ -250,11 +250,11 @@ var _ = Describe("quadlet system generator", func() {
generatedDir = filepath.Join(podmanTest.TempDir, "generated") generatedDir = filepath.Join(podmanTest.TempDir, "generated")
err = os.Mkdir(generatedDir, os.ModePerm) err = os.Mkdir(generatedDir, os.ModePerm)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
quadletDir = filepath.Join(podmanTest.TempDir, "quadlet") quadletDir = filepath.Join(podmanTest.TempDir, "quadlet")
err = os.Mkdir(quadletDir, os.ModePerm) err = os.Mkdir(quadletDir, os.ModePerm)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
}) })
AfterEach(func() { AfterEach(func() {
@ -270,7 +270,7 @@ var _ = Describe("quadlet system generator", func() {
// Write the tested file to the quadlet dir // Write the tested file to the quadlet dir
err = os.WriteFile(filepath.Join(quadletDir, fileName), testcase.data, 0644) err = os.WriteFile(filepath.Join(quadletDir, fileName), testcase.data, 0644)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// Run quadlet to convert the file // Run quadlet to convert the file
session := podmanTest.Quadlet([]string{"-no-kmsg-log", generatedDir}, quadletDir) session := podmanTest.Quadlet([]string{"-no-kmsg-log", generatedDir}, quadletDir)

View File

@ -251,7 +251,7 @@ var _ = Describe("Podman restart", func() {
It("podman restart --cidfile", func() { It("podman restart --cidfile", func() {
tmpDir, err := os.MkdirTemp("", "") tmpDir, err := os.MkdirTemp("", "")
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
tmpFile := tmpDir + "cid" tmpFile := tmpDir + "cid"
defer os.RemoveAll(tmpDir) defer os.RemoveAll(tmpDir)
@ -274,7 +274,7 @@ var _ = Describe("Podman restart", func() {
It("podman restart multiple --cidfile", func() { It("podman restart multiple --cidfile", func() {
tmpDir, err := os.MkdirTemp("", "") tmpDir, err := os.MkdirTemp("", "")
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
tmpFile1 := tmpDir + "cid-1" tmpFile1 := tmpDir + "cid-1"
tmpFile2 := tmpDir + "cid-2" tmpFile2 := tmpDir + "cid-2"

View File

@ -145,7 +145,7 @@ var _ = Describe("Podman rm", func() {
It("podman rm --cidfile", func() { It("podman rm --cidfile", func() {
tmpDir, err := os.MkdirTemp("", "") tmpDir, err := os.MkdirTemp("", "")
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
tmpFile := tmpDir + "cid" tmpFile := tmpDir + "cid"
defer os.RemoveAll(tmpDir) defer os.RemoveAll(tmpDir)
@ -166,7 +166,7 @@ var _ = Describe("Podman rm", func() {
It("podman rm multiple --cidfile", func() { It("podman rm multiple --cidfile", func() {
tmpDir, err := os.MkdirTemp("", "") tmpDir, err := os.MkdirTemp("", "")
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
tmpFile1 := tmpDir + "cid-1" tmpFile1 := tmpDir + "cid-1"
tmpFile2 := tmpDir + "cid-2" tmpFile2 := tmpDir + "cid-2"

View File

@ -103,7 +103,7 @@ profile aa-test-profile flags=(attach_disconnected,mediate_deleted) {
} }
` `
aaFile := filepath.Join(os.TempDir(), "aaFile") aaFile := filepath.Join(os.TempDir(), "aaFile")
Expect(os.WriteFile(aaFile, []byte(aaProfile), 0755)).To(BeNil()) Expect(os.WriteFile(aaFile, []byte(aaProfile), 0755)).To(Succeed())
parse := SystemExec("apparmor_parser", []string{"-Kr", aaFile}) parse := SystemExec("apparmor_parser", []string{"-Kr", aaFile})
Expect(parse).Should(Exit(0)) Expect(parse).Should(Exit(0))

View File

@ -86,16 +86,16 @@ var _ = Describe("Podman run with --cgroup-parent", func() {
// Move the container process to a sub cgroup // Move the container process to a sub cgroup
content, err := os.ReadFile(filepath.Join(cgroupRoot, containerCgroup, "cgroup.procs")) content, err := os.ReadFile(filepath.Join(cgroupRoot, containerCgroup, "cgroup.procs"))
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
oldSubCgroupPath := filepath.Join(cgroupRoot, containerCgroup, "old-container") oldSubCgroupPath := filepath.Join(cgroupRoot, containerCgroup, "old-container")
err = os.MkdirAll(oldSubCgroupPath, 0755) err = os.MkdirAll(oldSubCgroupPath, 0755)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
err = os.WriteFile(filepath.Join(oldSubCgroupPath, "cgroup.procs"), content, 0644) err = os.WriteFile(filepath.Join(oldSubCgroupPath, "cgroup.procs"), content, 0644)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
newCgroup := fmt.Sprintf("%s/new-container", containerCgroup) newCgroup := fmt.Sprintf("%s/new-container", containerCgroup)
err = os.MkdirAll(filepath.Join(cgroupRoot, newCgroup), 0755) err = os.MkdirAll(filepath.Join(cgroupRoot, newCgroup), 0755)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
run = podmanTest.Podman([]string{"--cgroup-manager=cgroupfs", "run", "--rm", "--cgroupns=host", fmt.Sprintf("--cgroup-parent=%s", newCgroup), fedoraMinimal, "cat", "/proc/self/cgroup"}) run = podmanTest.Podman([]string{"--cgroup-manager=cgroupfs", "run", "--rm", "--cgroupns=host", fmt.Sprintf("--cgroup-parent=%s", newCgroup), fedoraMinimal, "cat", "/proc/self/cgroup"})
run.WaitWithDefaultTimeout() run.WaitWithDefaultTimeout()

View File

@ -78,7 +78,7 @@ var _ = Describe("Podman run device", func() {
It("podman run device host device and container device parameter are directories", func() { It("podman run device host device and container device parameter are directories", func() {
SkipIfRootless("Cannot create devices in /dev in rootless mode") SkipIfRootless("Cannot create devices in /dev in rootless mode")
Expect(os.MkdirAll("/dev/foodevdir", os.ModePerm)).To(BeNil()) Expect(os.MkdirAll("/dev/foodevdir", os.ModePerm)).To(Succeed())
defer os.RemoveAll("/dev/foodevdir") defer os.RemoveAll("/dev/foodevdir")
mknod := SystemExec("mknod", []string{"/dev/foodevdir/null", "c", "1", "3"}) mknod := SystemExec("mknod", []string{"/dev/foodevdir/null", "c", "1", "3"})
@ -105,13 +105,13 @@ var _ = Describe("Podman run device", func() {
SkipIfRootless("Rootless will not be able to create files/folders in /etc") SkipIfRootless("Rootless will not be able to create files/folders in /etc")
cdiDir := "/etc/cdi" cdiDir := "/etc/cdi"
if _, err := os.Stat(cdiDir); os.IsNotExist(err) { if _, err := os.Stat(cdiDir); os.IsNotExist(err) {
Expect(os.MkdirAll(cdiDir, os.ModePerm)).To(BeNil()) Expect(os.MkdirAll(cdiDir, os.ModePerm)).To(Succeed())
} }
defer os.RemoveAll(cdiDir) defer os.RemoveAll(cdiDir)
cmd := exec.Command("cp", "cdi/device.json", cdiDir) cmd := exec.Command("cp", "cdi/device.json", cdiDir)
err = cmd.Run() err = cmd.Run()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
session := podmanTest.Podman([]string{"run", "-q", "--security-opt", "label=disable", "--device", "vendor.com/device=myKmsg", ALPINE, "test", "-c", "/dev/kmsg1"}) session := podmanTest.Podman([]string{"run", "-q", "--security-opt", "label=disable", "--device", "vendor.com/device=myKmsg", ALPINE, "test", "-c", "/dev/kmsg1"})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()

View File

@ -488,7 +488,7 @@ EXPOSE 2004-2005/tcp`, ALPINE)
It("podman run network bind to HostIP", func() { It("podman run network bind to HostIP", func() {
ip, err := utils.HostIP() ip, err := utils.HostIP()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
port := GetPort() port := GetPort()
slirp4netnsHelp := SystemExec("slirp4netns", []string{"--help"}) slirp4netnsHelp := SystemExec("slirp4netns", []string{"--help"})
@ -711,7 +711,7 @@ EXPOSE 2004-2005/tcp`, ALPINE)
addAddr := func(cidr string, containerInterface netlink.Link) error { addAddr := func(cidr string, containerInterface netlink.Link) error {
_, ipnet, err := net.ParseCIDR(cidr) _, ipnet, err := net.ParseCIDR(cidr)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
addr := &netlink.Addr{IPNet: ipnet, Label: ""} addr := &netlink.Addr{IPNet: ipnet, Label: ""}
if err := netlink.AddrAdd(containerInterface, addr); err != nil && err != syscall.EEXIST { if err := netlink.AddrAdd(containerInterface, addr); err != nil && err != syscall.EEXIST {
return err return err
@ -721,25 +721,25 @@ EXPOSE 2004-2005/tcp`, ALPINE)
loopbackup := func() { loopbackup := func() {
lo, err := netlink.LinkByName("lo") lo, err := netlink.LinkByName("lo")
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
err = netlink.LinkSetUp(lo) err = netlink.LinkSetUp(lo)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
} }
linkup := func(name string, mac string, addresses []string) { linkup := func(name string, mac string, addresses []string) {
linkAttr := netlink.NewLinkAttrs() linkAttr := netlink.NewLinkAttrs()
linkAttr.Name = name linkAttr.Name = name
m, err := net.ParseMAC(mac) m, err := net.ParseMAC(mac)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
linkAttr.HardwareAddr = m linkAttr.HardwareAddr = m
eth := &netlink.Dummy{LinkAttrs: linkAttr} eth := &netlink.Dummy{LinkAttrs: linkAttr}
err = netlink.LinkAdd(eth) err = netlink.LinkAdd(eth)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
err = netlink.LinkSetUp(eth) err = netlink.LinkSetUp(eth)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
for _, address := range addresses { for _, address := range addresses {
err := addAddr(address, eth) err := addAddr(address, eth)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
} }
} }
@ -765,14 +765,14 @@ EXPOSE 2004-2005/tcp`, ALPINE)
inspectOut := podmanTest.InspectContainer(name) inspectOut := podmanTest.InspectContainer(name)
Expect(inspectOut[0].NetworkSettings).To(HaveField("IPAddress", "10.25.40.0")) Expect(inspectOut[0].NetworkSettings).To(HaveField("IPAddress", "10.25.40.0"))
Expect(inspectOut[0].NetworkSettings).To(HaveField("IPPrefixLen", 24)) Expect(inspectOut[0].NetworkSettings).To(HaveField("IPPrefixLen", 24))
Expect(len(inspectOut[0].NetworkSettings.SecondaryIPAddresses)).To(Equal(1)) Expect(inspectOut[0].NetworkSettings.SecondaryIPAddresses).To(HaveLen(1))
Expect(inspectOut[0].NetworkSettings.SecondaryIPAddresses[0]).To(HaveField("Addr", "10.88.0.0")) Expect(inspectOut[0].NetworkSettings.SecondaryIPAddresses[0]).To(HaveField("Addr", "10.88.0.0"))
Expect(inspectOut[0].NetworkSettings.SecondaryIPAddresses[0]).To(HaveField("PrefixLength", 16)) Expect(inspectOut[0].NetworkSettings.SecondaryIPAddresses[0]).To(HaveField("PrefixLength", 16))
Expect(inspectOut[0].NetworkSettings).To(HaveField("GlobalIPv6Address", "fd04:3e42:4a4e:3381::")) Expect(inspectOut[0].NetworkSettings).To(HaveField("GlobalIPv6Address", "fd04:3e42:4a4e:3381::"))
Expect(inspectOut[0].NetworkSettings).To(HaveField("GlobalIPv6PrefixLen", 64)) Expect(inspectOut[0].NetworkSettings).To(HaveField("GlobalIPv6PrefixLen", 64))
Expect(len(inspectOut[0].NetworkSettings.SecondaryIPv6Addresses)).To(Equal(0)) Expect(inspectOut[0].NetworkSettings.SecondaryIPv6Addresses).To(BeEmpty())
Expect(inspectOut[0].NetworkSettings).To(HaveField("MacAddress", "46:7f:45:6e:4f:c8")) Expect(inspectOut[0].NetworkSettings).To(HaveField("MacAddress", "46:7f:45:6e:4f:c8"))
Expect(len(inspectOut[0].NetworkSettings.AdditionalMacAddresses)).To(Equal(1)) Expect(inspectOut[0].NetworkSettings.AdditionalMacAddresses).To(HaveLen(1))
Expect(inspectOut[0].NetworkSettings.AdditionalMacAddresses[0]).To(Equal("56:6e:35:5d:3e:a8")) Expect(inspectOut[0].NetworkSettings.AdditionalMacAddresses[0]).To(Equal("56:6e:35:5d:3e:a8"))
Expect(inspectOut[0].NetworkSettings).To(HaveField("Gateway", "10.25.40.0")) Expect(inspectOut[0].NetworkSettings).To(HaveField("Gateway", "10.25.40.0"))
@ -797,7 +797,7 @@ EXPOSE 2004-2005/tcp`, ALPINE)
inspectOut := podmanTest.InspectContainer(name) inspectOut := podmanTest.InspectContainer(name)
Expect(inspectOut[0].NetworkSettings).To(HaveField("IPAddress", "")) Expect(inspectOut[0].NetworkSettings).To(HaveField("IPAddress", ""))
Expect(len(inspectOut[0].NetworkSettings.Networks)).To(Equal(0)) Expect(inspectOut[0].NetworkSettings.Networks).To(BeEmpty())
}) })
It("podman inspect can handle joined network ns with multiple interfaces", func() { It("podman inspect can handle joined network ns with multiple interfaces", func() {

View File

@ -117,13 +117,13 @@ var _ = Describe("Podman run ns", func() {
SkipIfRootlessCgroupsV1("Not supported for rootless + CgroupsV1") SkipIfRootlessCgroupsV1("Not supported for rootless + CgroupsV1")
cmd := exec.Command("ls", "-l", "/proc/self/ns/pid") cmd := exec.Command("ls", "-l", "/proc/self/ns/pid")
res, err := cmd.Output() res, err := cmd.Output()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
fields := strings.Split(string(res), " ") fields := strings.Split(string(res), " ")
hostPidNS := strings.TrimSuffix(fields[len(fields)-1], "\n") hostPidNS := strings.TrimSuffix(fields[len(fields)-1], "\n")
cmd = exec.Command("ls", "-l", "/proc/self/ns/ipc") cmd = exec.Command("ls", "-l", "/proc/self/ns/ipc")
res, err = cmd.Output() res, err = cmd.Output()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
fields = strings.Split(string(res), " ") fields = strings.Split(string(res), " ")
hostIpcNS := strings.TrimSuffix(fields[len(fields)-1], "\n") hostIpcNS := strings.TrimSuffix(fields[len(fields)-1], "\n")

View File

@ -134,7 +134,7 @@ var _ = Describe("Podman privileged container tests", func() {
It("podman privileged should restart after host devices change", func() { It("podman privileged should restart after host devices change", func() {
containerName := "privileged-restart-test" containerName := "privileged-restart-test"
SkipIfRootless("Cannot create devices in /dev in rootless mode") SkipIfRootless("Cannot create devices in /dev in rootless mode")
Expect(os.MkdirAll("/dev/foodevdir", os.ModePerm)).To(BeNil()) Expect(os.MkdirAll("/dev/foodevdir", os.ModePerm)).To(Succeed())
mknod := SystemExec("mknod", []string{"/dev/foodevdir/null", "c", "1", "3"}) mknod := SystemExec("mknod", []string{"/dev/foodevdir/null", "c", "1", "3"})
mknod.WaitWithDefaultTimeout() mknod.WaitWithDefaultTimeout()
@ -158,7 +158,7 @@ var _ = Describe("Podman privileged container tests", func() {
It("run no-new-privileges test", func() { It("run no-new-privileges test", func() {
// Check if our kernel is new enough // Check if our kernel is new enough
k, err := IsKernelNewerThan("4.14") k, err := IsKernelNewerThan("4.14")
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
if !k { if !k {
Skip("Kernel is not new enough to test this feature") Skip("Kernel is not new enough to test this feature")
} }

View File

@ -298,7 +298,7 @@ var _ = Describe("Podman run", func() {
runtime := podmanTest.OCIRuntime runtime := podmanTest.OCIRuntime
podmanTest.OCIRuntime = filepath.Join(podmanTest.TempDir, "kata-runtime") podmanTest.OCIRuntime = filepath.Join(podmanTest.TempDir, "kata-runtime")
err := os.Symlink("/bin/true", podmanTest.OCIRuntime) err := os.Symlink("/bin/true", podmanTest.OCIRuntime)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
if IsRemote() { if IsRemote() {
podmanTest.StopRemoteService() podmanTest.StopRemoteService()
podmanTest.StartRemoteService() podmanTest.StartRemoteService()

View File

@ -226,7 +226,7 @@ var _ = Describe("Podman run", func() {
tarball := filepath.Join(tempdir, "rootfs.tar") tarball := filepath.Join(tempdir, "rootfs.tar")
err := os.Mkdir(rootfs, 0770) err := os.Mkdir(rootfs, 0770)
Expect(err).Should(BeNil()) Expect(err).ShouldNot(HaveOccurred())
// Change image in predictable way to validate export // Change image in predictable way to validate export
csession := podmanTest.Podman([]string{"run", "--name", uniqueString, ALPINE, csession := podmanTest.Podman([]string{"run", "--name", uniqueString, ALPINE,
@ -638,7 +638,7 @@ USER bin`, BB)
Expect(session.OutputToString()).To(Equal("111")) Expect(session.OutputToString()).To(Equal("111"))
currentOOMScoreAdj, err := os.ReadFile("/proc/self/oom_score_adj") currentOOMScoreAdj, err := os.ReadFile("/proc/self/oom_score_adj")
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
session = podmanTest.Podman([]string{"run", "--rm", fedoraMinimal, "cat", "/proc/self/oom_score_adj"}) session = podmanTest.Podman([]string{"run", "--rm", fedoraMinimal, "cat", "/proc/self/oom_score_adj"})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0)) Expect(session).Should(Exit(0))
@ -651,7 +651,7 @@ USER bin`, BB)
var l syscall.Rlimit var l syscall.Rlimit
err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &l) err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &l)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
session := podmanTest.Podman([]string{"run", "--rm", "--ulimit", "host", fedoraMinimal, "ulimit", "-Hn"}) session := podmanTest.Podman([]string{"run", "--rm", "--ulimit", "host", fedoraMinimal, "ulimit", "-Hn"})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
@ -659,7 +659,7 @@ USER bin`, BB)
ulimitCtrStr := strings.TrimSpace(session.OutputToString()) ulimitCtrStr := strings.TrimSpace(session.OutputToString())
ulimitCtr, err := strconv.ParseUint(ulimitCtrStr, 10, 0) ulimitCtr, err := strconv.ParseUint(ulimitCtrStr, 10, 0)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(ulimitCtr).Should(BeNumerically(">=", l.Max)) Expect(ulimitCtr).Should(BeNumerically(">=", l.Max))
}) })
@ -669,7 +669,7 @@ USER bin`, BB)
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0)) Expect(session).Should(Exit(0))
err := os.Remove(tempdir + "cidfile") err := os.Remove(tempdir + "cidfile")
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
}) })
It("podman run sysctl test", func() { It("podman run sysctl test", func() {
@ -795,7 +795,7 @@ USER bin`, BB)
Net: "unixgram", Net: "unixgram",
} }
socket, err := net.ListenUnixgram("unixgram", &addr) socket, err := net.ListenUnixgram("unixgram", &addr)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
defer os.Remove(sock) defer os.Remove(sock)
defer socket.Close() defer socket.Close()
@ -805,7 +805,7 @@ USER bin`, BB)
session := podmanTest.Podman([]string{"run", ALPINE, "printenv", "NOTIFY_SOCKET"}) session := podmanTest.Podman([]string{"run", ALPINE, "printenv", "NOTIFY_SOCKET"})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0)) Expect(session).Should(Exit(0))
Expect(len(session.OutputToStringArray())).To(BeNumerically(">", 0)) Expect(session.OutputToStringArray()).ToNot(BeEmpty())
}) })
It("podman run log-opt", func() { It("podman run log-opt", func() {
@ -814,7 +814,7 @@ USER bin`, BB)
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0)) Expect(session).Should(Exit(0))
_, err := os.Stat(log) _, err := os.Stat(log)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
_ = os.Remove(log) _ = os.Remove(log)
}) })
@ -868,28 +868,28 @@ echo -n %s >%s
SkipIfRemote("--default-mount-file option is not supported in podman-remote") SkipIfRemote("--default-mount-file option is not supported in podman-remote")
containersDir := filepath.Join(podmanTest.TempDir, "containers") containersDir := filepath.Join(podmanTest.TempDir, "containers")
err := os.MkdirAll(containersDir, 0755) err := os.MkdirAll(containersDir, 0755)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
secretsDir := filepath.Join(podmanTest.TempDir, "rhel", "secrets") secretsDir := filepath.Join(podmanTest.TempDir, "rhel", "secrets")
err = os.MkdirAll(secretsDir, 0755) err = os.MkdirAll(secretsDir, 0755)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
mountsFile := filepath.Join(containersDir, "mounts.conf") mountsFile := filepath.Join(containersDir, "mounts.conf")
mountString := secretsDir + ":/run/secrets" mountString := secretsDir + ":/run/secrets"
err = os.WriteFile(mountsFile, []byte(mountString), 0755) err = os.WriteFile(mountsFile, []byte(mountString), 0755)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
secretsFile := filepath.Join(secretsDir, "test.txt") secretsFile := filepath.Join(secretsDir, "test.txt")
secretsString := "Testing secrets mount. I am mounted!" secretsString := "Testing secrets mount. I am mounted!"
err = os.WriteFile(secretsFile, []byte(secretsString), 0755) err = os.WriteFile(secretsFile, []byte(secretsString), 0755)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
targetDir := tempdir + "/symlink/target" targetDir := tempdir + "/symlink/target"
err = os.MkdirAll(targetDir, 0755) err = os.MkdirAll(targetDir, 0755)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
keyFile := filepath.Join(targetDir, "key.pem") keyFile := filepath.Join(targetDir, "key.pem")
err = os.WriteFile(keyFile, []byte(mountString), 0755) err = os.WriteFile(keyFile, []byte(mountString), 0755)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
execSession := SystemExec("ln", []string{"-s", targetDir, filepath.Join(secretsDir, "mysymlink")}) execSession := SystemExec("ln", []string{"-s", targetDir, filepath.Join(secretsDir, "mysymlink")})
Expect(execSession).Should(Exit(0)) Expect(execSession).Should(Exit(0))
@ -908,7 +908,7 @@ echo -n %s >%s
SkipIfRootless("rootless can not manipulate system-fips file") SkipIfRootless("rootless can not manipulate system-fips file")
fipsFile := "/etc/system-fips" fipsFile := "/etc/system-fips"
err = os.WriteFile(fipsFile, []byte{}, 0755) err = os.WriteFile(fipsFile, []byte{}, 0755)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
session := podmanTest.Podman([]string{"run", "--rm", ALPINE, "ls", "/run/secrets"}) session := podmanTest.Podman([]string{"run", "--rm", ALPINE, "ls", "/run/secrets"})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
@ -916,7 +916,7 @@ echo -n %s >%s
Expect(session.OutputToString()).To(ContainSubstring("system-fips")) Expect(session.OutputToString()).To(ContainSubstring("system-fips"))
err = os.Remove(fipsFile) err = os.Remove(fipsFile)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
}) })
It("podman run without group-add", func() { It("podman run without group-add", func() {
@ -1064,13 +1064,13 @@ USER mail`, BB)
It("podman run --volumes-from flag", func() { It("podman run --volumes-from flag", func() {
vol := filepath.Join(podmanTest.TempDir, "vol-test") vol := filepath.Join(podmanTest.TempDir, "vol-test")
err := os.MkdirAll(vol, 0755) err := os.MkdirAll(vol, 0755)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
filename := "test.txt" filename := "test.txt"
volFile := filepath.Join(vol, filename) volFile := filepath.Join(vol, filename)
data := "Testing --volumes-from!!!" data := "Testing --volumes-from!!!"
err = os.WriteFile(volFile, []byte(data), 0755) err = os.WriteFile(volFile, []byte(data), 0755)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
mountpoint := "/myvol/" mountpoint := "/myvol/"
session := podmanTest.Podman([]string{"create", "--volume", vol + ":" + mountpoint + ":z", ALPINE, "cat", mountpoint + filename}) session := podmanTest.Podman([]string{"create", "--volume", vol + ":" + mountpoint + ":z", ALPINE, "cat", mountpoint + filename})
@ -1096,13 +1096,13 @@ USER mail`, BB)
It("podman run --volumes-from flag options", func() { It("podman run --volumes-from flag options", func() {
vol := filepath.Join(podmanTest.TempDir, "vol-test") vol := filepath.Join(podmanTest.TempDir, "vol-test")
err := os.MkdirAll(vol, 0755) err := os.MkdirAll(vol, 0755)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
filename := "test.txt" filename := "test.txt"
volFile := filepath.Join(vol, filename) volFile := filepath.Join(vol, filename)
data := "Testing --volumes-from!!!" data := "Testing --volumes-from!!!"
err = os.WriteFile(volFile, []byte(data), 0755) err = os.WriteFile(volFile, []byte(data), 0755)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
mountpoint := "/myvol/" mountpoint := "/myvol/"
session := podmanTest.Podman([]string{"create", "--volume", vol + ":" + mountpoint, ALPINE, "cat", mountpoint + filename}) session := podmanTest.Podman([]string{"create", "--volume", vol + ":" + mountpoint, ALPINE, "cat", mountpoint + filename})
@ -1162,10 +1162,10 @@ USER mail`, BB)
It("podman run --volumes flag with multiple volumes", func() { It("podman run --volumes flag with multiple volumes", func() {
vol1 := filepath.Join(podmanTest.TempDir, "vol-test1") vol1 := filepath.Join(podmanTest.TempDir, "vol-test1")
err := os.MkdirAll(vol1, 0755) err := os.MkdirAll(vol1, 0755)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
vol2 := filepath.Join(podmanTest.TempDir, "vol-test2") vol2 := filepath.Join(podmanTest.TempDir, "vol-test2")
err = os.MkdirAll(vol2, 0755) err = os.MkdirAll(vol2, 0755)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
session := podmanTest.Podman([]string{"run", "--volume", vol1 + ":/myvol1:z", "--volume", vol2 + ":/myvol2:z", ALPINE, "touch", "/myvol2/foo.txt"}) session := podmanTest.Podman([]string{"run", "--volume", vol1 + ":/myvol1:z", "--volume", vol2 + ":/myvol2:z", ALPINE, "touch", "/myvol2/foo.txt"})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
@ -1175,7 +1175,7 @@ USER mail`, BB)
It("podman run --volumes flag with empty host dir", func() { It("podman run --volumes flag with empty host dir", func() {
vol1 := filepath.Join(podmanTest.TempDir, "vol-test1") vol1 := filepath.Join(podmanTest.TempDir, "vol-test1")
err := os.MkdirAll(vol1, 0755) err := os.MkdirAll(vol1, 0755)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
session := podmanTest.Podman([]string{"run", "--volume", ":/myvol1:z", ALPINE, "touch", "/myvol2/foo.txt"}) session := podmanTest.Podman([]string{"run", "--volume", ":/myvol1:z", ALPINE, "touch", "/myvol2/foo.txt"})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
@ -1190,10 +1190,10 @@ USER mail`, BB)
It("podman run --mount flag with multiple mounts", func() { It("podman run --mount flag with multiple mounts", func() {
vol1 := filepath.Join(podmanTest.TempDir, "vol-test1") vol1 := filepath.Join(podmanTest.TempDir, "vol-test1")
err := os.MkdirAll(vol1, 0755) err := os.MkdirAll(vol1, 0755)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
vol2 := filepath.Join(podmanTest.TempDir, "vol-test2") vol2 := filepath.Join(podmanTest.TempDir, "vol-test2")
err = os.MkdirAll(vol2, 0755) err = os.MkdirAll(vol2, 0755)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
session := podmanTest.Podman([]string{"run", "--mount", "type=bind,src=" + vol1 + ",target=/myvol1,z", "--mount", "type=bind,src=" + vol2 + ",target=/myvol2,z", ALPINE, "touch", "/myvol2/foo.txt"}) session := podmanTest.Podman([]string{"run", "--mount", "type=bind,src=" + vol1 + ",target=/myvol1,z", "--mount", "type=bind,src=" + vol2 + ",target=/myvol2,z", ALPINE, "touch", "/myvol2/foo.txt"})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
@ -1203,10 +1203,10 @@ USER mail`, BB)
It("podman run findmnt nothing shared", func() { It("podman run findmnt nothing shared", func() {
vol1 := filepath.Join(podmanTest.TempDir, "vol-test1") vol1 := filepath.Join(podmanTest.TempDir, "vol-test1")
err := os.MkdirAll(vol1, 0755) err := os.MkdirAll(vol1, 0755)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
vol2 := filepath.Join(podmanTest.TempDir, "vol-test2") vol2 := filepath.Join(podmanTest.TempDir, "vol-test2")
err = os.MkdirAll(vol2, 0755) err = os.MkdirAll(vol2, 0755)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
session := podmanTest.Podman([]string{"run", "--volume", vol1 + ":/myvol1:z", "--volume", vol2 + ":/myvol2:z", fedoraMinimal, "findmnt", "-o", "TARGET,PROPAGATION"}) session := podmanTest.Podman([]string{"run", "--volume", vol1 + ":/myvol1:z", "--volume", vol2 + ":/myvol2:z", fedoraMinimal, "findmnt", "-o", "TARGET,PROPAGATION"})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
@ -1217,10 +1217,10 @@ USER mail`, BB)
It("podman run findmnt shared", func() { It("podman run findmnt shared", func() {
vol1 := filepath.Join(podmanTest.TempDir, "vol-test1") vol1 := filepath.Join(podmanTest.TempDir, "vol-test1")
err := os.MkdirAll(vol1, 0755) err := os.MkdirAll(vol1, 0755)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
vol2 := filepath.Join(podmanTest.TempDir, "vol-test2") vol2 := filepath.Join(podmanTest.TempDir, "vol-test2")
err = os.MkdirAll(vol2, 0755) err = os.MkdirAll(vol2, 0755)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
session := podmanTest.Podman([]string{"run", "--volume", vol1 + ":/myvol1:z", "--volume", vol2 + ":/myvol2:shared,z", fedoraMinimal, "findmnt", "-o", "TARGET,PROPAGATION"}) session := podmanTest.Podman([]string{"run", "--volume", vol1 + ":/myvol1:z", "--volume", vol2 + ":/myvol2:shared,z", fedoraMinimal, "findmnt", "-o", "TARGET,PROPAGATION"})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
@ -1368,11 +1368,11 @@ USER mail`, BB)
It("podman run with restart-policy always restarts containers", func() { It("podman run with restart-policy always restarts containers", func() {
testDir := filepath.Join(podmanTest.RunRoot, "restart-test") testDir := filepath.Join(podmanTest.RunRoot, "restart-test")
err := os.MkdirAll(testDir, 0755) err := os.MkdirAll(testDir, 0755)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
aliveFile := filepath.Join(testDir, "running") aliveFile := filepath.Join(testDir, "running")
file, err := os.Create(aliveFile) file, err := os.Create(aliveFile)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
file.Close() file.Close()
session := podmanTest.Podman([]string{"run", "-dt", "--restart", "always", "-v", fmt.Sprintf("%s:/tmp/runroot:Z", testDir), ALPINE, "sh", "-c", "touch /tmp/runroot/ran && while test -r /tmp/runroot/running; do sleep 0.1s; done"}) session := podmanTest.Podman([]string{"run", "-dt", "--restart", "always", "-v", fmt.Sprintf("%s:/tmp/runroot:Z", testDir), ALPINE, "sh", "-c", "touch /tmp/runroot/ran && while test -r /tmp/runroot/running; do sleep 0.1s; done"})
@ -1384,14 +1384,14 @@ USER mail`, BB)
if _, err := os.Stat(testFile); err == nil { if _, err := os.Stat(testFile); err == nil {
found = true found = true
err = os.Remove(testFile) err = os.Remove(testFile)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
break break
} }
} }
Expect(found).To(BeTrue()) Expect(found).To(BeTrue())
err = os.Remove(aliveFile) err = os.Remove(aliveFile)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
@ -1492,7 +1492,7 @@ USER mail`, BB)
} }
curCgroupsBytes, err := os.ReadFile("/proc/self/cgroup") curCgroupsBytes, err := os.ReadFile("/proc/self/cgroup")
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
var curCgroups string = string(curCgroupsBytes) var curCgroups string = string(curCgroupsBytes)
fmt.Printf("Output:\n%s\n", curCgroups) fmt.Printf("Output:\n%s\n", curCgroups)
Expect(curCgroups).To(Not(Equal(""))) Expect(curCgroups).To(Not(Equal("")))
@ -1509,7 +1509,7 @@ USER mail`, BB)
Expect(pid).To(Not(Equal(0))) Expect(pid).To(Not(Equal(0)))
ctrCgroupsBytes, err := os.ReadFile(fmt.Sprintf("/proc/%d/cgroup", pid)) ctrCgroupsBytes, err := os.ReadFile(fmt.Sprintf("/proc/%d/cgroup", pid))
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
var ctrCgroups string = string(ctrCgroupsBytes) var ctrCgroups string = string(ctrCgroupsBytes)
fmt.Printf("Output\n:%s\n", ctrCgroups) fmt.Printf("Output\n:%s\n", ctrCgroups)
Expect(curCgroups).To(Not(Equal(ctrCgroups))) Expect(curCgroups).To(Not(Equal(ctrCgroups)))
@ -1555,7 +1555,7 @@ USER mail`, BB)
It("podman run --preserve-fds", func() { It("podman run --preserve-fds", func() {
devNull, err := os.Open("/dev/null") devNull, err := os.Open("/dev/null")
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
defer devNull.Close() defer devNull.Close()
files := []*os.File{ files := []*os.File{
devNull, devNull,
@ -1583,14 +1583,14 @@ USER mail`, BB)
It("podman run --tz", func() { It("podman run --tz", func() {
testDir := filepath.Join(podmanTest.RunRoot, "tz-test") testDir := filepath.Join(podmanTest.RunRoot, "tz-test")
err := os.MkdirAll(testDir, 0755) err := os.MkdirAll(testDir, 0755)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
tzFile := filepath.Join(testDir, "tzfile.txt") tzFile := filepath.Join(testDir, "tzfile.txt")
file, err := os.Create(tzFile) file, err := os.Create(tzFile)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
_, err = file.WriteString("Hello") _, err = file.WriteString("Hello")
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
file.Close() file.Close()
badTZFile := fmt.Sprintf("../../../%s", tzFile) badTZFile := fmt.Sprintf("../../../%s", tzFile)
@ -1600,7 +1600,7 @@ USER mail`, BB)
Expect(session.ErrorToString()).To(ContainSubstring("finding timezone for container")) Expect(session.ErrorToString()).To(ContainSubstring("finding timezone for container"))
err = os.Remove(tzFile) err = os.Remove(tzFile)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
session = podmanTest.Podman([]string{"run", "--tz", "foo", "--rm", ALPINE, "date"}) session = podmanTest.Podman([]string{"run", "--tz", "foo", "--rm", ALPINE, "date"})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
@ -1740,7 +1740,7 @@ WORKDIR /madethis`, BB)
secretsString := "somesecretdata" secretsString := "somesecretdata"
secretFilePath := filepath.Join(podmanTest.TempDir, "secret") secretFilePath := filepath.Join(podmanTest.TempDir, "secret")
err := os.WriteFile(secretFilePath, []byte(secretsString), 0755) err := os.WriteFile(secretFilePath, []byte(secretsString), 0755)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
session := podmanTest.Podman([]string{"secret", "create", "mysecret", secretFilePath}) session := podmanTest.Podman([]string{"secret", "create", "mysecret", secretFilePath})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
@ -1762,7 +1762,7 @@ WORKDIR /madethis`, BB)
secretsString := "somesecretdata" secretsString := "somesecretdata"
secretFilePath := filepath.Join(podmanTest.TempDir, "secret") secretFilePath := filepath.Join(podmanTest.TempDir, "secret")
err := os.WriteFile(secretFilePath, []byte(secretsString), 0755) err := os.WriteFile(secretFilePath, []byte(secretsString), 0755)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
session := podmanTest.Podman([]string{"secret", "create", "mysecret", secretFilePath}) session := podmanTest.Podman([]string{"secret", "create", "mysecret", secretFilePath})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
@ -1784,7 +1784,7 @@ WORKDIR /madethis`, BB)
secretsString := "somesecretdata" secretsString := "somesecretdata"
secretFilePath := filepath.Join(podmanTest.TempDir, "secret") secretFilePath := filepath.Join(podmanTest.TempDir, "secret")
err := os.WriteFile(secretFilePath, []byte(secretsString), 0755) err := os.WriteFile(secretFilePath, []byte(secretsString), 0755)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
session := podmanTest.Podman([]string{"secret", "create", "mysecret_target", secretFilePath}) session := podmanTest.Podman([]string{"secret", "create", "mysecret_target", secretFilePath})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
@ -1806,7 +1806,7 @@ WORKDIR /madethis`, BB)
secretsString := "somesecretdata" secretsString := "somesecretdata"
secretFilePath := filepath.Join(podmanTest.TempDir, "secret") secretFilePath := filepath.Join(podmanTest.TempDir, "secret")
err := os.WriteFile(secretFilePath, []byte(secretsString), 0755) err := os.WriteFile(secretFilePath, []byte(secretsString), 0755)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
session := podmanTest.Podman([]string{"secret", "create", "mysecret_target2", secretFilePath}) session := podmanTest.Podman([]string{"secret", "create", "mysecret_target2", secretFilePath})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
@ -1828,7 +1828,7 @@ WORKDIR /madethis`, BB)
secretsString := "somesecretdata" secretsString := "somesecretdata"
secretFilePath := filepath.Join(podmanTest.TempDir, "secret") secretFilePath := filepath.Join(podmanTest.TempDir, "secret")
err := os.WriteFile(secretFilePath, []byte(secretsString), 0755) err := os.WriteFile(secretFilePath, []byte(secretsString), 0755)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
session := podmanTest.Podman([]string{"secret", "create", "mysecret", secretFilePath}) session := podmanTest.Podman([]string{"secret", "create", "mysecret", secretFilePath})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
@ -1844,7 +1844,7 @@ WORKDIR /madethis`, BB)
secretsString := "somesecretdata" secretsString := "somesecretdata"
secretFilePath := filepath.Join(podmanTest.TempDir, "secret") secretFilePath := filepath.Join(podmanTest.TempDir, "secret")
err := os.WriteFile(secretFilePath, []byte(secretsString), 0755) err := os.WriteFile(secretFilePath, []byte(secretsString), 0755)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
session := podmanTest.Podman([]string{"secret", "create", "mysecret", secretFilePath}) session := podmanTest.Podman([]string{"secret", "create", "mysecret", secretFilePath})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
@ -1860,7 +1860,7 @@ WORKDIR /madethis`, BB)
secretsString := "somesecretdata" secretsString := "somesecretdata"
secretFilePath := filepath.Join(podmanTest.TempDir, "secret") secretFilePath := filepath.Join(podmanTest.TempDir, "secret")
err := os.WriteFile(secretFilePath, []byte(secretsString), 0755) err := os.WriteFile(secretFilePath, []byte(secretsString), 0755)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
session := podmanTest.Podman([]string{"secret", "create", "mysecret", secretFilePath}) session := podmanTest.Podman([]string{"secret", "create", "mysecret", secretFilePath})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
@ -1887,7 +1887,7 @@ WORKDIR /madethis`, BB)
secretsString := "somesecretdata" secretsString := "somesecretdata"
secretFilePath := filepath.Join(podmanTest.TempDir, "secret") secretFilePath := filepath.Join(podmanTest.TempDir, "secret")
err := os.WriteFile(secretFilePath, []byte(secretsString), 0755) err := os.WriteFile(secretFilePath, []byte(secretsString), 0755)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
session := podmanTest.Podman([]string{"secret", "create", "mysecret", secretFilePath}) session := podmanTest.Podman([]string{"secret", "create", "mysecret", secretFilePath})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
@ -1903,7 +1903,7 @@ WORKDIR /madethis`, BB)
secretsString := "somesecretdata" secretsString := "somesecretdata"
secretFilePath := filepath.Join(podmanTest.TempDir, "secret") secretFilePath := filepath.Join(podmanTest.TempDir, "secret")
err := os.WriteFile(secretFilePath, []byte(secretsString), 0755) err := os.WriteFile(secretFilePath, []byte(secretsString), 0755)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
session := podmanTest.Podman([]string{"secret", "create", "mysecret", secretFilePath}) session := podmanTest.Podman([]string{"secret", "create", "mysecret", secretFilePath})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
@ -1968,12 +1968,12 @@ WORKDIR /madethis`, BB)
Expect(session).Should(Exit(0)) Expect(session).Should(Exit(0))
readFirstLine := func(path string) string { readFirstLine := func(path string) string {
content, err := os.ReadFile(path) content, err := os.ReadFile(path)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
return strings.Split(string(content), "\n")[0] return strings.Split(string(content), "\n")[0]
} }
containerPID := readFirstLine(pidfile) containerPID := readFirstLine(pidfile)
_, err = strconv.Atoi(containerPID) // Make sure it's a proper integer _, err = strconv.Atoi(containerPID) // Make sure it's a proper integer
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
}) })
It("podman run check personality support", func() { It("podman run check personality support", func() {

View File

@ -18,7 +18,7 @@ func createContainersConfFileWithCustomUserns(pTest *PodmanTestIntegration, user
configPath := filepath.Join(pTest.TempDir, "containers.conf") configPath := filepath.Join(pTest.TempDir, "containers.conf")
containersConf := []byte(fmt.Sprintf("[containers]\nuserns = \"%s\"\n", userns)) containersConf := []byte(fmt.Sprintf("[containers]\nuserns = \"%s\"\n", userns))
err := os.WriteFile(configPath, containersConf, os.ModePerm) err := os.WriteFile(configPath, containersConf, os.ModePerm)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// Set custom containers.conf file // Set custom containers.conf file
os.Setenv("CONTAINERS_CONF", configPath) os.Setenv("CONTAINERS_CONF", configPath)
@ -63,7 +63,7 @@ var _ = Describe("Podman UserNS support", func() {
// we don't break this feature for podman-remote. // we don't break this feature for podman-remote.
It("podman build with --userns=auto", func() { It("podman build with --userns=auto", func() {
u, err := user.Current() u, err := user.Current()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
name := u.Name name := u.Name
if name == "root" { if name == "root" {
name = "containers" name = "containers"
@ -154,7 +154,7 @@ var _ = Describe("Podman UserNS support", func() {
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0)) Expect(session).Should(Exit(0))
u, err := user.Current() u, err := user.Current()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(session.OutputToString()).To(ContainSubstring(u.Name)) Expect(session.OutputToString()).To(ContainSubstring(u.Name))
}) })
@ -198,7 +198,7 @@ var _ = Describe("Podman UserNS support", func() {
It("podman --userns=auto", func() { It("podman --userns=auto", func() {
u, err := user.Current() u, err := user.Current()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
name := u.Name name := u.Name
if name == "root" { if name == "root" {
name = "containers" name = "containers"
@ -235,7 +235,7 @@ var _ = Describe("Podman UserNS support", func() {
It("podman --userns=auto:size=%d", func() { It("podman --userns=auto:size=%d", func() {
u, err := user.Current() u, err := user.Current()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
name := u.Name name := u.Name
if name == "root" { if name == "root" {
@ -273,7 +273,7 @@ var _ = Describe("Podman UserNS support", func() {
It("podman --userns=auto:uidmapping=", func() { It("podman --userns=auto:uidmapping=", func() {
u, err := user.Current() u, err := user.Current()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
name := u.Name name := u.Name
if name == "root" { if name == "root" {
@ -302,7 +302,7 @@ var _ = Describe("Podman UserNS support", func() {
It("podman --userns=auto:gidmapping=", func() { It("podman --userns=auto:gidmapping=", func() {
u, err := user.Current() u, err := user.Current()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
name := u.Name name := u.Name
if name == "root" { if name == "root" {

View File

@ -153,12 +153,12 @@ var _ = Describe("Podman run with volumes", func() {
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
mountPath := filepath.Join(podmanTest.TempDir, "secrets") mountPath := filepath.Join(podmanTest.TempDir, "secrets")
err := os.Mkdir(mountPath, 0755) err := os.Mkdir(mountPath, 0755)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
testFile := filepath.Join(mountPath, "test1") testFile := filepath.Join(mountPath, "test1")
f, err := os.Create(testFile) f, err := os.Create(testFile)
Expect(err).To(BeNil(), "os.Create(testfile)") Expect(err).ToNot(HaveOccurred(), "os.Create(testfile)")
f.Close() f.Close()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
session := podmanTest.Podman([]string{"run", "-v", fmt.Sprintf("%s:/data", mountPath), REDIS_IMAGE, "ls", "/data/test1"}) session := podmanTest.Podman([]string{"run", "-v", fmt.Sprintf("%s:/data", mountPath), REDIS_IMAGE, "ls", "/data/test1"})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0)) Expect(session).Should(Exit(0))
@ -284,12 +284,12 @@ var _ = Describe("Podman run with volumes", func() {
// create persistent upperdir on host // create persistent upperdir on host
upperDir := filepath.Join(tempdir, "upper") upperDir := filepath.Join(tempdir, "upper")
err := os.Mkdir(upperDir, 0755) err := os.Mkdir(upperDir, 0755)
Expect(err).To(BeNil(), "mkdir "+upperDir) Expect(err).ToNot(HaveOccurred(), "mkdir "+upperDir)
// create persistent workdir on host // create persistent workdir on host
workDir := filepath.Join(tempdir, "work") workDir := filepath.Join(tempdir, "work")
err = os.Mkdir(workDir, 0755) err = os.Mkdir(workDir, 0755)
Expect(err).To(BeNil(), "mkdir "+workDir) Expect(err).ToNot(HaveOccurred(), "mkdir "+workDir)
overlayOpts := fmt.Sprintf("upperdir=%s,workdir=%s", upperDir, workDir) overlayOpts := fmt.Sprintf("upperdir=%s,workdir=%s", upperDir, workDir)
@ -338,17 +338,17 @@ var _ = Describe("Podman run with volumes", func() {
// Use bindsource instead of named volume // Use bindsource instead of named volume
bindSource := filepath.Join(tempdir, "bindsource") bindSource := filepath.Join(tempdir, "bindsource")
err := os.Mkdir(bindSource, 0755) err := os.Mkdir(bindSource, 0755)
Expect(err).To(BeNil(), "mkdir "+bindSource) Expect(err).ToNot(HaveOccurred(), "mkdir "+bindSource)
// create persistent upperdir on host // create persistent upperdir on host
upperDir := filepath.Join(tempdir, "upper") upperDir := filepath.Join(tempdir, "upper")
err = os.Mkdir(upperDir, 0755) err = os.Mkdir(upperDir, 0755)
Expect(err).To(BeNil(), "mkdir "+upperDir) Expect(err).ToNot(HaveOccurred(), "mkdir "+upperDir)
// create persistent workdir on host // create persistent workdir on host
workDir := filepath.Join(tempdir, "work") workDir := filepath.Join(tempdir, "work")
err = os.Mkdir(workDir, 0755) err = os.Mkdir(workDir, 0755)
Expect(err).To(BeNil(), "mkdir "+workDir) Expect(err).ToNot(HaveOccurred(), "mkdir "+workDir)
overlayOpts := fmt.Sprintf("upperdir=%s,workdir=%s", upperDir, workDir) overlayOpts := fmt.Sprintf("upperdir=%s,workdir=%s", upperDir, workDir)
@ -385,7 +385,7 @@ var _ = Describe("Podman run with volumes", func() {
// Volume not mounted on create // Volume not mounted on create
mountCmd1, err := Start(exec.Command("mount"), GinkgoWriter, GinkgoWriter) mountCmd1, err := Start(exec.Command("mount"), GinkgoWriter, GinkgoWriter)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
mountCmd1.Wait(90) mountCmd1.Wait(90)
Expect(mountCmd1).Should(Exit(0)) Expect(mountCmd1).Should(Exit(0))
os.Stdout.Sync() os.Stdout.Sync()
@ -401,7 +401,7 @@ var _ = Describe("Podman run with volumes", func() {
// Volume now mounted as container is running // Volume now mounted as container is running
mountCmd2, err := Start(exec.Command("mount"), GinkgoWriter, GinkgoWriter) mountCmd2, err := Start(exec.Command("mount"), GinkgoWriter, GinkgoWriter)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
mountCmd2.Wait(90) mountCmd2.Wait(90)
Expect(mountCmd2).Should(Exit(0)) Expect(mountCmd2).Should(Exit(0))
os.Stdout.Sync() os.Stdout.Sync()
@ -422,7 +422,7 @@ var _ = Describe("Podman run with volumes", func() {
// Ensure volume is unmounted // Ensure volume is unmounted
mountCmd3, err := Start(exec.Command("mount"), GinkgoWriter, GinkgoWriter) mountCmd3, err := Start(exec.Command("mount"), GinkgoWriter, GinkgoWriter)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
mountCmd3.Wait(90) mountCmd3.Wait(90)
Expect(mountCmd3).Should(Exit(0)) Expect(mountCmd3).Should(Exit(0))
os.Stdout.Sync() os.Stdout.Sync()
@ -621,7 +621,7 @@ RUN sh -c "cd /etc/apk && ln -s ../../testfile"`, ALPINE)
fileName := "thisIsATestFile" fileName := "thisIsATestFile"
file, err := os.Create(filepath.Join(path, fileName)) file, err := os.Create(filepath.Join(path, fileName))
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
defer file.Close() defer file.Close()
runLs := podmanTest.Podman([]string{"run", "-t", "-i", "--rm", "-v", fmt.Sprintf("%v:/etc/ssl", volName), ALPINE, "ls", "-1", "/etc/ssl"}) runLs := podmanTest.Podman([]string{"run", "-t", "-i", "--rm", "-v", fmt.Sprintf("%v:/etc/ssl", volName), ALPINE, "ls", "-1", "/etc/ssl"})
@ -665,7 +665,7 @@ VOLUME /test/`, ALPINE)
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
testFile := filepath.Join(mountPath, "test1") testFile := filepath.Join(mountPath, "test1")
f, err := os.Create(testFile) f, err := os.Create(testFile)
Expect(err).To(BeNil(), "os.Create "+testFile) Expect(err).ToNot(HaveOccurred(), "os.Create "+testFile)
f.Close() f.Close()
// Make sure host directory gets mounted in to container as overlay // Make sure host directory gets mounted in to container as overlay
@ -679,7 +679,7 @@ VOLUME /test/`, ALPINE)
// Test overlay mount when lowerdir is relative path. // Test overlay mount when lowerdir is relative path.
f, err = os.Create("hello") f, err = os.Create("hello")
Expect(err).To(BeNil(), "os.Create") Expect(err).ToNot(HaveOccurred(), "os.Create")
f.Close() f.Close()
session = podmanTest.Podman([]string{"run", "--rm", "-v", ".:/app:O", ALPINE, "ls", "/app"}) session = podmanTest.Podman([]string{"run", "--rm", "-v", ".:/app:O", ALPINE, "ls", "/app"})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
@ -691,7 +691,7 @@ VOLUME /test/`, ALPINE)
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0)) Expect(session).Should(Exit(0))
_, err = os.Stat(filepath.Join(mountPath, "container")) _, err = os.Stat(filepath.Join(mountPath, "container"))
Expect(err).To(Not(BeNil())) Expect(err).To(HaveOccurred())
// Make sure modifications in container disappear when container is stopped // Make sure modifications in container disappear when container is stopped
session = podmanTest.Podman([]string{"create", "-v", fmt.Sprintf("%s:/run/test:O", mountPath), ALPINE, "top"}) session = podmanTest.Podman([]string{"create", "-v", fmt.Sprintf("%s:/run/test:O", mountPath), ALPINE, "top"})
@ -723,11 +723,11 @@ VOLUME /test/`, ALPINE)
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
testFile := filepath.Join(mountPath, "test1") testFile := filepath.Join(mountPath, "test1")
f, err := os.Create(testFile) f, err := os.Create(testFile)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
f.Close() f.Close()
mountSrc := filepath.Join(podmanTest.TempDir, "vol-test1") mountSrc := filepath.Join(podmanTest.TempDir, "vol-test1")
err = os.MkdirAll(mountSrc, 0755) err = os.MkdirAll(mountSrc, 0755)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
mountDest := "/run/test" mountDest := "/run/test"
volName := "myvol" volName := "myvol"
@ -761,7 +761,7 @@ VOLUME /test/`, ALPINE)
SkipIfRemote("Overlay volumes only work locally") SkipIfRemote("Overlay volumes only work locally")
u, err := user.Current() u, err := user.Current()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
name := u.Username name := u.Username
if name == "root" { if name == "root" {
name = "containers" name = "containers"
@ -808,7 +808,7 @@ VOLUME /test/`, ALPINE)
It("podman run with --mount and U flag", func() { It("podman run with --mount and U flag", func() {
u, err := user.Current() u, err := user.Current()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
name := u.Username name := u.Username
if name == "root" { if name == "root" {
name = "containers" name = "containers"
@ -927,7 +927,7 @@ USER testuser`, fedoraMinimal)
It("podman run with -v $SRC:/run does not create /run/.containerenv", func() { It("podman run with -v $SRC:/run does not create /run/.containerenv", func() {
mountSrc := filepath.Join(podmanTest.TempDir, "vol-test1") mountSrc := filepath.Join(podmanTest.TempDir, "vol-test1")
err := os.MkdirAll(mountSrc, 0755) err := os.MkdirAll(mountSrc, 0755)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
session := podmanTest.Podman([]string{"run", "-v", mountSrc + ":/run", ALPINE, "true"}) session := podmanTest.Podman([]string{"run", "-v", mountSrc + ":/run", ALPINE, "true"})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
@ -935,7 +935,7 @@ USER testuser`, fedoraMinimal)
// the file should not have been created // the file should not have been created
_, err = os.Stat(filepath.Join(mountSrc, ".containerenv")) _, err = os.Stat(filepath.Join(mountSrc, ".containerenv"))
Expect(err).To(Not(BeNil())) Expect(err).To(HaveOccurred())
}) })
It("podman volume with uid and gid works", func() { It("podman volume with uid and gid works", func() {

View File

@ -48,7 +48,7 @@ var _ = Describe("Podman run", func() {
It("podman run a container using a --workdir under a bind mount", func() { It("podman run a container using a --workdir under a bind mount", func() {
volume, err := CreateTempDirInTempDir() volume, err := CreateTempDirInTempDir()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
session := podmanTest.Podman([]string{"run", "--volume", fmt.Sprintf("%s:/var_ovl/:O", volume), "--workdir", "/var_ovl/log", ALPINE, "true"}) session := podmanTest.Podman([]string{"run", "--volume", fmt.Sprintf("%s:/var_ovl/:O", volume), "--workdir", "/var_ovl/log", ALPINE, "true"})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()

View File

@ -154,10 +154,10 @@ var _ = Describe("Podman save", func() {
} }
tempGNUPGHOME := filepath.Join(podmanTest.TempDir, "tmpGPG") tempGNUPGHOME := filepath.Join(podmanTest.TempDir, "tmpGPG")
err := os.Mkdir(tempGNUPGHOME, os.ModePerm) err := os.Mkdir(tempGNUPGHOME, os.ModePerm)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
origGNUPGHOME := os.Getenv("GNUPGHOME") origGNUPGHOME := os.Getenv("GNUPGHOME")
err = os.Setenv("GNUPGHOME", tempGNUPGHOME) err = os.Setenv("GNUPGHOME", tempGNUPGHOME)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
defer os.Setenv("GNUPGHOME", origGNUPGHOME) defer os.Setenv("GNUPGHOME", origGNUPGHOME)
port := 5000 port := 5000
@ -173,7 +173,7 @@ var _ = Describe("Podman save", func() {
cmd := exec.Command("gpg", "--import", "sign/secret-key.asc") cmd := exec.Command("gpg", "--import", "sign/secret-key.asc")
err = cmd.Run() err = cmd.Run()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
defaultYaml := filepath.Join(podmanTest.TempDir, "default.yaml") defaultYaml := filepath.Join(podmanTest.TempDir, "default.yaml")
cmd = exec.Command("cp", "/etc/containers/registries.d/default.yaml", defaultYaml) cmd = exec.Command("cp", "/etc/containers/registries.d/default.yaml", defaultYaml)
@ -187,13 +187,13 @@ var _ = Describe("Podman save", func() {
}() }()
cmd = exec.Command("cp", "sign/key.gpg", "/tmp/key.gpg") cmd = exec.Command("cp", "sign/key.gpg", "/tmp/key.gpg")
Expect(cmd.Run()).To(BeNil()) Expect(cmd.Run()).To(Succeed())
sigstore := ` sigstore := `
default-docker: default-docker:
sigstore: file:///var/lib/containers/sigstore sigstore: file:///var/lib/containers/sigstore
sigstore-staging: file:///var/lib/containers/sigstore sigstore-staging: file:///var/lib/containers/sigstore
` `
Expect(os.WriteFile("/etc/containers/registries.d/default.yaml", []byte(sigstore), 0755)).To(BeNil()) Expect(os.WriteFile("/etc/containers/registries.d/default.yaml", []byte(sigstore), 0755)).To(Succeed())
session = podmanTest.Podman([]string{"tag", ALPINE, "localhost:5000/alpine"}) session = podmanTest.Podman([]string{"tag", ALPINE, "localhost:5000/alpine"})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()

View File

@ -122,7 +122,7 @@ registries = ['{{.Host}}:{{.Port}}']`
contents := make([]entities.ImageSearchReport, 0) contents := make([]entities.ImageSearchReport, 0)
err := json.Unmarshal(search.Out.Contents(), &contents) err := json.Unmarshal(search.Out.Contents(), &contents)
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
Expect(len(contents)).To(BeNumerically(">", 0), "No results from image search") Expect(contents).ToNot(BeEmpty(), "No results from image search")
for _, element := range contents { for _, element := range contents {
Expect(element.Description).ToNot(HaveSuffix("...")) Expect(element.Description).ToNot(HaveSuffix("..."))
} }
@ -255,7 +255,7 @@ registries = ['{{.Host}}:{{.Port}}']`
searchEmpty := podmanTest.Podman([]string{"search", fmt.Sprintf("%s/", ep.Address()), "--tls-verify=false"}) searchEmpty := podmanTest.Podman([]string{"search", fmt.Sprintf("%s/", ep.Address()), "--tls-verify=false"})
searchEmpty.WaitWithDefaultTimeout() searchEmpty.WaitWithDefaultTimeout()
Expect(searchEmpty).Should(Exit(0)) Expect(searchEmpty).Should(Exit(0))
Expect(len(searchEmpty.OutputToStringArray())).To(BeNumerically(">=", 1)) Expect(searchEmpty.OutputToStringArray()).ToNot(BeEmpty())
Expect(search.OutputToString()).To(ContainSubstring("my-alpine")) Expect(search.OutputToString()).To(ContainSubstring("my-alpine"))
}) })

View File

@ -37,7 +37,7 @@ var _ = Describe("Podman secret", func() {
It("podman secret create", func() { It("podman secret create", func() {
secretFilePath := filepath.Join(podmanTest.TempDir, "secret") secretFilePath := filepath.Join(podmanTest.TempDir, "secret")
err := os.WriteFile(secretFilePath, []byte("mysecret"), 0755) err := os.WriteFile(secretFilePath, []byte("mysecret"), 0755)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
session := podmanTest.Podman([]string{"secret", "create", "-d", "file", "--driver-opts", "opt1=val", "a", secretFilePath}) session := podmanTest.Podman([]string{"secret", "create", "-d", "file", "--driver-opts", "opt1=val", "a", secretFilePath})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
@ -57,7 +57,7 @@ var _ = Describe("Podman secret", func() {
It("podman secret create bad name should fail", func() { It("podman secret create bad name should fail", func() {
secretFilePath := filepath.Join(podmanTest.TempDir, "secret") secretFilePath := filepath.Join(podmanTest.TempDir, "secret")
err := os.WriteFile(secretFilePath, []byte("mysecret"), 0755) err := os.WriteFile(secretFilePath, []byte("mysecret"), 0755)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
session := podmanTest.Podman([]string{"secret", "create", "?!", secretFilePath}) session := podmanTest.Podman([]string{"secret", "create", "?!", secretFilePath})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
@ -67,7 +67,7 @@ var _ = Describe("Podman secret", func() {
It("podman secret inspect", func() { It("podman secret inspect", func() {
secretFilePath := filepath.Join(podmanTest.TempDir, "secret") secretFilePath := filepath.Join(podmanTest.TempDir, "secret")
err := os.WriteFile(secretFilePath, []byte("mysecret"), 0755) err := os.WriteFile(secretFilePath, []byte("mysecret"), 0755)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
session := podmanTest.Podman([]string{"secret", "create", "a", secretFilePath}) session := podmanTest.Podman([]string{"secret", "create", "a", secretFilePath})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
@ -83,7 +83,7 @@ var _ = Describe("Podman secret", func() {
It("podman secret inspect with --format", func() { It("podman secret inspect with --format", func() {
secretFilePath := filepath.Join(podmanTest.TempDir, "secret") secretFilePath := filepath.Join(podmanTest.TempDir, "secret")
err := os.WriteFile(secretFilePath, []byte("mysecret"), 0755) err := os.WriteFile(secretFilePath, []byte("mysecret"), 0755)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
session := podmanTest.Podman([]string{"secret", "create", "a", secretFilePath}) session := podmanTest.Podman([]string{"secret", "create", "a", secretFilePath})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
@ -99,7 +99,7 @@ var _ = Describe("Podman secret", func() {
It("podman secret inspect with --pretty", func() { It("podman secret inspect with --pretty", func() {
secretFilePath := filepath.Join(podmanTest.TempDir, "secret") secretFilePath := filepath.Join(podmanTest.TempDir, "secret")
err := os.WriteFile(secretFilePath, []byte("mysecret"), 0755) err := os.WriteFile(secretFilePath, []byte("mysecret"), 0755)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
session := podmanTest.Podman([]string{"secret", "create", "a", secretFilePath}) session := podmanTest.Podman([]string{"secret", "create", "a", secretFilePath})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
@ -116,7 +116,7 @@ var _ = Describe("Podman secret", func() {
It("podman secret inspect multiple secrets", func() { It("podman secret inspect multiple secrets", func() {
secretFilePath := filepath.Join(podmanTest.TempDir, "secret") secretFilePath := filepath.Join(podmanTest.TempDir, "secret")
err := os.WriteFile(secretFilePath, []byte("mysecret"), 0755) err := os.WriteFile(secretFilePath, []byte("mysecret"), 0755)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
session := podmanTest.Podman([]string{"secret", "create", "a", secretFilePath}) session := podmanTest.Podman([]string{"secret", "create", "a", secretFilePath})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
@ -137,7 +137,7 @@ var _ = Describe("Podman secret", func() {
It("podman secret inspect bogus", func() { It("podman secret inspect bogus", func() {
secretFilePath := filepath.Join(podmanTest.TempDir, "secret") secretFilePath := filepath.Join(podmanTest.TempDir, "secret")
err := os.WriteFile(secretFilePath, []byte("mysecret"), 0755) err := os.WriteFile(secretFilePath, []byte("mysecret"), 0755)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
inspect := podmanTest.Podman([]string{"secret", "inspect", "bogus"}) inspect := podmanTest.Podman([]string{"secret", "inspect", "bogus"})
inspect.WaitWithDefaultTimeout() inspect.WaitWithDefaultTimeout()
@ -147,7 +147,7 @@ var _ = Describe("Podman secret", func() {
It("podman secret ls", func() { It("podman secret ls", func() {
secretFilePath := filepath.Join(podmanTest.TempDir, "secret") secretFilePath := filepath.Join(podmanTest.TempDir, "secret")
err := os.WriteFile(secretFilePath, []byte("mysecret"), 0755) err := os.WriteFile(secretFilePath, []byte("mysecret"), 0755)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
session := podmanTest.Podman([]string{"secret", "create", "a", secretFilePath}) session := podmanTest.Podman([]string{"secret", "create", "a", secretFilePath})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
@ -163,7 +163,7 @@ var _ = Describe("Podman secret", func() {
It("podman secret ls --quiet", func() { It("podman secret ls --quiet", func() {
secretFilePath := filepath.Join(podmanTest.TempDir, "secret") secretFilePath := filepath.Join(podmanTest.TempDir, "secret")
err := os.WriteFile(secretFilePath, []byte("mysecret"), 0755) err := os.WriteFile(secretFilePath, []byte("mysecret"), 0755)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
secretName := "a" secretName := "a"
@ -193,7 +193,7 @@ var _ = Describe("Podman secret", func() {
It("podman secret ls with filters", func() { It("podman secret ls with filters", func() {
secretFilePath := filepath.Join(podmanTest.TempDir, "secret") secretFilePath := filepath.Join(podmanTest.TempDir, "secret")
err := os.WriteFile(secretFilePath, []byte("mysecret"), 0755) err := os.WriteFile(secretFilePath, []byte("mysecret"), 0755)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
secret1 := "Secret1" secret1 := "Secret1"
secret2 := "Secret2" secret2 := "Secret2"
@ -247,7 +247,7 @@ var _ = Describe("Podman secret", func() {
It("podman secret ls with Go template", func() { It("podman secret ls with Go template", func() {
secretFilePath := filepath.Join(podmanTest.TempDir, "secret") secretFilePath := filepath.Join(podmanTest.TempDir, "secret")
err := os.WriteFile(secretFilePath, []byte("mysecret"), 0755) err := os.WriteFile(secretFilePath, []byte("mysecret"), 0755)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
session := podmanTest.Podman([]string{"secret", "create", "a", secretFilePath}) session := podmanTest.Podman([]string{"secret", "create", "a", secretFilePath})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
@ -263,7 +263,7 @@ var _ = Describe("Podman secret", func() {
It("podman secret rm", func() { It("podman secret rm", func() {
secretFilePath := filepath.Join(podmanTest.TempDir, "secret") secretFilePath := filepath.Join(podmanTest.TempDir, "secret")
err := os.WriteFile(secretFilePath, []byte("mysecret"), 0755) err := os.WriteFile(secretFilePath, []byte("mysecret"), 0755)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
session := podmanTest.Podman([]string{"secret", "create", "a", secretFilePath}) session := podmanTest.Podman([]string{"secret", "create", "a", secretFilePath})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
@ -284,7 +284,7 @@ var _ = Describe("Podman secret", func() {
It("podman secret rm --all", func() { It("podman secret rm --all", func() {
secretFilePath := filepath.Join(podmanTest.TempDir, "secret") secretFilePath := filepath.Join(podmanTest.TempDir, "secret")
err := os.WriteFile(secretFilePath, []byte("mysecret"), 0755) err := os.WriteFile(secretFilePath, []byte("mysecret"), 0755)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
session := podmanTest.Podman([]string{"secret", "create", "a", secretFilePath}) session := podmanTest.Podman([]string{"secret", "create", "a", secretFilePath})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
@ -328,7 +328,7 @@ var _ = Describe("Podman secret", func() {
It("podman secret with labels", func() { It("podman secret with labels", func() {
secretFilePath := filepath.Join(podmanTest.TempDir, "secret") secretFilePath := filepath.Join(podmanTest.TempDir, "secret")
err := os.WriteFile(secretFilePath, []byte("mysecret"), 0755) err := os.WriteFile(secretFilePath, []byte("mysecret"), 0755)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
session := podmanTest.Podman([]string{"secret", "create", "--label", "foo=bar", "a", secretFilePath}) session := podmanTest.Podman([]string{"secret", "create", "--label", "foo=bar", "a", secretFilePath})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()

View File

@ -204,12 +204,12 @@ var _ = Describe("Podman start", func() {
Expect(session).Should(Exit(0)) Expect(session).Should(Exit(0))
readFirstLine := func(path string) string { readFirstLine := func(path string) string {
content, err := os.ReadFile(path) content, err := os.ReadFile(path)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
return strings.Split(string(content), "\n")[0] return strings.Split(string(content), "\n")[0]
} }
containerPID := readFirstLine(pidfile) containerPID := readFirstLine(pidfile)
_, err = strconv.Atoi(containerPID) // Make sure it's a proper integer _, err = strconv.Atoi(containerPID) // Make sure it's a proper integer
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
}) })
It("podman start container --filter", func() { It("podman start container --filter", func() {

View File

@ -231,9 +231,9 @@ var _ = Describe("Podman stats", func() {
Expect(limits[0]).ToNot(Equal(limits[2])) Expect(limits[0]).ToNot(Equal(limits[2]))
defaultLimit, err := strconv.Atoi(limits[0]) defaultLimit, err := strconv.Atoi(limits[0])
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
customLimit, err := strconv.Atoi(limits[2]) customLimit, err := strconv.Atoi(limits[2])
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(customLimit).To(BeNumerically("<", defaultLimit)) Expect(customLimit).To(BeNumerically("<", defaultLimit))
}) })

View File

@ -276,7 +276,7 @@ var _ = Describe("Podman stop", func() {
It("podman stop --cidfile", func() { It("podman stop --cidfile", func() {
tmpDir, err := os.MkdirTemp("", "") tmpDir, err := os.MkdirTemp("", "")
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
tmpFile := tmpDir + "cid" tmpFile := tmpDir + "cid"
defer os.RemoveAll(tmpDir) defer os.RemoveAll(tmpDir)
@ -300,7 +300,7 @@ var _ = Describe("Podman stop", func() {
It("podman stop multiple --cidfile", func() { It("podman stop multiple --cidfile", func() {
tmpDir, err := os.MkdirTemp("", "") tmpDir, err := os.MkdirTemp("", "")
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
tmpFile1 := tmpDir + "cid-1" tmpFile1 := tmpDir + "cid-1"
tmpFile2 := tmpDir + "cid-2" tmpFile2 := tmpDir + "cid-2"

View File

@ -51,7 +51,7 @@ WantedBy=default.target
SkipIfContainerized("test does not have systemd as pid 1") SkipIfContainerized("test does not have systemd as pid 1")
sysFile := os.WriteFile("/etc/systemd/system/redis.service", []byte(systemdUnitFile), 0644) sysFile := os.WriteFile("/etc/systemd/system/redis.service", []byte(systemdUnitFile), 0644)
Expect(sysFile).To(BeNil()) Expect(sysFile).ToNot(HaveOccurred())
defer func() { defer func() {
stop := SystemExec("bash", []string{"-c", "systemctl stop redis"}) stop := SystemExec("bash", []string{"-c", "systemctl stop redis"})
os.Remove("/etc/systemd/system/redis.service") os.Remove("/etc/systemd/system/redis.service")
@ -137,7 +137,7 @@ CMD /usr/lib/systemd/systemd`, ALPINE)
containerfilePath := filepath.Join(podmanTest.TempDir, "Containerfile") containerfilePath := filepath.Join(podmanTest.TempDir, "Containerfile")
err := os.WriteFile(containerfilePath, []byte(containerfile), 0755) err := os.WriteFile(containerfilePath, []byte(containerfile), 0755)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
session := podmanTest.Podman([]string{"build", "-t", "systemd", "--file", containerfilePath, podmanTest.TempDir}) session := podmanTest.Podman([]string{"build", "-t", "systemd", "--file", containerfilePath, podmanTest.TempDir})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0)) Expect(session).Should(Exit(0))
@ -167,7 +167,7 @@ CMD /usr/lib/systemd/systemd`, ALPINE)
pidFile := strings.TrimSuffix(session.OutputToString(), "\n") pidFile := strings.TrimSuffix(session.OutputToString(), "\n")
_, err := os.ReadFile(pidFile) _, err := os.ReadFile(pidFile)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
}) })
It("podman create container with systemd=always triggers systemd mode", func() { It("podman create container with systemd=always triggers systemd mode", func() {

View File

@ -90,7 +90,7 @@ var _ = Describe("Toolbox-specific testing", func() {
var err error var err error
err = syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rlimit) err = syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rlimit)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
fmt.Printf("Expected value: %d", rlimit.Max) fmt.Printf("Expected value: %d", rlimit.Max)
session = podmanTest.Podman([]string{"create", "--name", "test", "--ulimit", "host", ALPINE, session = podmanTest.Podman([]string{"create", "--name", "test", "--ulimit", "host", ALPINE,
@ -107,7 +107,7 @@ var _ = Describe("Toolbox-specific testing", func() {
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0)) Expect(session).Should(Exit(0))
containerHardLimit, err = strconv.Atoi(strings.Trim(session.OutputToString(), "\n")) containerHardLimit, err = strconv.Atoi(strings.Trim(session.OutputToString(), "\n"))
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
Expect(containerHardLimit).To(BeNumerically(">=", rlimit.Max)) Expect(containerHardLimit).To(BeNumerically(">=", rlimit.Max))
}) })
@ -128,11 +128,11 @@ var _ = Describe("Toolbox-specific testing", func() {
// ('1K-blocks') needs to be extracted manually. // ('1K-blocks') needs to be extracted manually.
cmd = exec.Command("df", "/dev/shm") cmd = exec.Command("df", "/dev/shm")
res, err := cmd.Output() res, err := cmd.Output()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
lines := strings.SplitN(string(res), "\n", 2) lines := strings.SplitN(string(res), "\n", 2)
fields := strings.Fields(lines[len(lines)-1]) fields := strings.Fields(lines[len(lines)-1])
hostShmSize, err = strconv.Atoi(fields[1]) hostShmSize, err = strconv.Atoi(fields[1])
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
session = podmanTest.Podman([]string{"create", "--name", "test", "--ipc=host", "--pid=host", ALPINE, session = podmanTest.Podman([]string{"create", "--name", "test", "--ipc=host", "--pid=host", ALPINE,
"sleep", "1000"}) "sleep", "1000"})
@ -150,7 +150,7 @@ var _ = Describe("Toolbox-specific testing", func() {
lines = session.OutputToStringArray() lines = session.OutputToStringArray()
fields = strings.Fields(lines[len(lines)-1]) fields = strings.Fields(lines[len(lines)-1])
containerShmSize, err = strconv.Atoi(fields[1]) containerShmSize, err = strconv.Atoi(fields[1])
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
// In some cases it may happen that the size of /dev/shm is not exactly // In some cases it may happen that the size of /dev/shm is not exactly
// equal. Therefore it's fine if there's a slight tolerance between the // equal. Therefore it's fine if there's a slight tolerance between the
@ -173,16 +173,16 @@ var _ = Describe("Toolbox-specific testing", func() {
var err error var err error
currentUser, err := user.Current() currentUser, err := user.Current()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
currentGroup, err := user.LookupGroupId(currentUser.Gid) currentGroup, err := user.LookupGroupId(currentUser.Gid)
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
session = podmanTest.Podman([]string{"create", "--name", "test", "--userns=keep-id", ALPINE, session = podmanTest.Podman([]string{"create", "--name", "test", "--userns=keep-id", ALPINE,
"sleep", "1000"}) "sleep", "1000"})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0)) Expect(session).Should(Exit(0))
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
session = podmanTest.Podman([]string{"start", "test"}) session = podmanTest.Podman([]string{"start", "test"})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
@ -374,7 +374,7 @@ var _ = Describe("Toolbox-specific testing", func() {
SkipIfNotRootless("only meaningful when run rootless") SkipIfNotRootless("only meaningful when run rootless")
var session *PodmanSessionIntegration var session *PodmanSessionIntegration
currentUser, err := user.Current() currentUser, err := user.Current()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
session = podmanTest.Podman([]string{"run", "-v", fmt.Sprintf("%s:%s", currentUser.HomeDir, currentUser.HomeDir), "--userns=keep-id", fedoraToolbox, "sh", "-c", "echo $HOME"}) session = podmanTest.Podman([]string{"run", "-v", fmt.Sprintf("%s:%s", currentUser.HomeDir, currentUser.HomeDir), "--userns=keep-id", fedoraToolbox, "sh", "-c", "echo $HOME"})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()

View File

@ -17,7 +17,7 @@ var _ = Describe("Podman update", func() {
BeforeEach(func() { BeforeEach(func() {
tempdir, err = CreateTempDirInTempDir() tempdir, err = CreateTempDirInTempDir()
Expect(err).To(BeNil()) Expect(err).ToNot(HaveOccurred())
podmanTest = PodmanTestCreate(tempdir) podmanTest = PodmanTestCreate(tempdir)
podmanTest.Setup() podmanTest.Setup()
}) })

View File

@ -52,7 +52,7 @@ var _ = Describe("Common functions test", func() {
if !empty { if !empty {
f, _ := os.Create(path) f, _ := os.Create(path)
_, err := f.WriteString(txt) _, err := f.WriteString(txt)
Expect(err).To(BeNil(), "Failed to write data.") Expect(err).ToNot(HaveOccurred(), "Failed to write data.")
f.Close() f.Close()
} }
@ -104,13 +104,13 @@ var _ = Describe("Common functions test", func() {
} }
testByte, err := json.Marshal(testData) testByte, err := json.Marshal(testData)
Expect(err).To(BeNil(), "Failed to marshal data.") Expect(err).ToNot(HaveOccurred(), "Failed to marshal data.")
err = WriteJSONFile(testByte, "/tmp/testJSON") err = WriteJSONFile(testByte, "/tmp/testJSON")
Expect(err).To(BeNil(), "Failed to write JSON to file.") Expect(err).ToNot(HaveOccurred(), "Failed to write JSON to file.")
read, err := os.Open("/tmp/testJSON") read, err := os.Open("/tmp/testJSON")
Expect(err).To(BeNil(), "Can not find the JSON file after we write it.") Expect(err).ToNot(HaveOccurred(), "Can not find the JSON file after we write it.")
defer read.Close() defer read.Close()
bytes, err := io.ReadAll(read) bytes, err := io.ReadAll(read)
@ -139,7 +139,7 @@ var _ = Describe("Common functions test", func() {
if createFile { if createFile {
f, _ := os.Create(path) f, _ := os.Create(path)
_, err := f.WriteString(txt) _, err := f.WriteString(txt)
Expect(err).To(BeNil(), "Failed to write data.") Expect(err).ToNot(HaveOccurred(), "Failed to write data.")
f.Close() f.Close()
} }
ProcessOneCgroupPath = path ProcessOneCgroupPath = path