aboutsummaryrefslogtreecommitdiff
path: root/libpod/state_test.go
diff options
context:
space:
mode:
authorMiloslav Trmač <mitr@redhat.com>2018-07-25 04:12:29 +0200
committerAtomic Bot <atomic-devel@projectatomic.io>2018-07-26 20:47:31 +0000
commit24fe6e950c5c384a052b320b3473b1fa70c088f9 (patch)
treeae2aa19c8364d6ae93c20fb8222549e685a448fa /libpod/state_test.go
parent9ff4f40094c5863951c965f6cdf5844843a3fe1b (diff)
downloadpodman-24fe6e950c5c384a052b320b3473b1fa70c088f9.tar.gz
podman-24fe6e950c5c384a052b320b3473b1fa70c088f9.tar.bz2
podman-24fe6e950c5c384a052b320b3473b1fa70c088f9.zip
Use testify/require in a few places to avoid panics in tests
Signed-off-by: Miloslav Trmač <mitr@redhat.com> Closes: #1115 Approved by: rhatdan
Diffstat (limited to 'libpod/state_test.go')
-rw-r--r--libpod/state_test.go15
1 files changed, 8 insertions, 7 deletions
diff --git a/libpod/state_test.go b/libpod/state_test.go
index 30638024c..827847049 100644
--- a/libpod/state_test.go
+++ b/libpod/state_test.go
@@ -10,6 +10,7 @@ import (
"github.com/containers/storage"
"github.com/stretchr/testify/assert"
+ "github.com/stretchr/testify/require"
)
// Returns state, tmp directory containing all state files, locks directory
@@ -275,7 +276,7 @@ func TestAddCtrDepInPodFails(t *testing.T) {
ctrs, err := state.AllContainers()
assert.NoError(t, err)
- assert.Equal(t, 1, len(ctrs))
+ require.Len(t, ctrs, 1)
testContainersEqual(t, testCtr1, ctrs[0])
})
@@ -688,7 +689,7 @@ func TestSaveAndUpdateContainer(t *testing.T) {
assert.NoError(t, err)
retrievedCtr, err := state.Container(testCtr.ID())
- assert.NoError(t, err)
+ require.NoError(t, err)
retrievedCtr.state.State = ContainerStateStopped
retrievedCtr.state.ExitCode = 127
@@ -880,7 +881,7 @@ func TestGetAllContainersWithOneContainer(t *testing.T) {
ctrs, err := state.AllContainers()
assert.NoError(t, err)
- assert.Equal(t, 1, len(ctrs))
+ require.Len(t, ctrs, 1)
testContainersEqual(t, testCtr, ctrs[0])
})
@@ -2335,7 +2336,7 @@ func TestPodContainersOneContainer(t *testing.T) {
ctrs, err := state.PodContainers(testPod)
assert.NoError(t, err)
- assert.Equal(t, 1, len(ctrs))
+ require.Len(t, ctrs, 1)
testContainersEqual(t, testCtr, ctrs[0])
})
@@ -2637,11 +2638,11 @@ func TestAddContainerToPodSucceeds(t *testing.T) {
ctrs, err := state.PodContainers(testPod)
assert.NoError(t, err)
- assert.Equal(t, 1, len(ctrs))
+ require.Len(t, ctrs, 1)
allCtrs, err := state.AllContainers()
assert.NoError(t, err)
- assert.Equal(t, 1, len(allCtrs))
+ require.Len(t, allCtrs, 1)
testContainersEqual(t, testCtr, ctrs[0])
testContainersEqual(t, ctrs[0], allCtrs[0])
@@ -2703,7 +2704,7 @@ func TestAddContainerToPodWithAddContainer(t *testing.T) {
ctrs, err := state.PodContainers(testPod)
assert.NoError(t, err)
- assert.Equal(t, 1, len(ctrs))
+ require.Len(t, ctrs, 1)
allCtrs, err := state.AllContainers()
assert.NoError(t, err)