mirror of
https://github.com/containers/podman.git
synced 2025-07-15 03:02:52 +08:00
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
This commit is contained in:

committed by
Atomic Bot

parent
9ff4f40094
commit
24fe6e950c
@ -10,6 +10,7 @@ import (
|
|||||||
|
|
||||||
"github.com/containers/storage"
|
"github.com/containers/storage"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Returns state, tmp directory containing all state files, locks directory
|
// Returns state, tmp directory containing all state files, locks directory
|
||||||
@ -275,7 +276,7 @@ func TestAddCtrDepInPodFails(t *testing.T) {
|
|||||||
|
|
||||||
ctrs, err := state.AllContainers()
|
ctrs, err := state.AllContainers()
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, 1, len(ctrs))
|
require.Len(t, ctrs, 1)
|
||||||
|
|
||||||
testContainersEqual(t, testCtr1, ctrs[0])
|
testContainersEqual(t, testCtr1, ctrs[0])
|
||||||
})
|
})
|
||||||
@ -688,7 +689,7 @@ func TestSaveAndUpdateContainer(t *testing.T) {
|
|||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
retrievedCtr, err := state.Container(testCtr.ID())
|
retrievedCtr, err := state.Container(testCtr.ID())
|
||||||
assert.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
retrievedCtr.state.State = ContainerStateStopped
|
retrievedCtr.state.State = ContainerStateStopped
|
||||||
retrievedCtr.state.ExitCode = 127
|
retrievedCtr.state.ExitCode = 127
|
||||||
@ -880,7 +881,7 @@ func TestGetAllContainersWithOneContainer(t *testing.T) {
|
|||||||
|
|
||||||
ctrs, err := state.AllContainers()
|
ctrs, err := state.AllContainers()
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, 1, len(ctrs))
|
require.Len(t, ctrs, 1)
|
||||||
|
|
||||||
testContainersEqual(t, testCtr, ctrs[0])
|
testContainersEqual(t, testCtr, ctrs[0])
|
||||||
})
|
})
|
||||||
@ -2335,7 +2336,7 @@ func TestPodContainersOneContainer(t *testing.T) {
|
|||||||
|
|
||||||
ctrs, err := state.PodContainers(testPod)
|
ctrs, err := state.PodContainers(testPod)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, 1, len(ctrs))
|
require.Len(t, ctrs, 1)
|
||||||
|
|
||||||
testContainersEqual(t, testCtr, ctrs[0])
|
testContainersEqual(t, testCtr, ctrs[0])
|
||||||
})
|
})
|
||||||
@ -2637,11 +2638,11 @@ func TestAddContainerToPodSucceeds(t *testing.T) {
|
|||||||
|
|
||||||
ctrs, err := state.PodContainers(testPod)
|
ctrs, err := state.PodContainers(testPod)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, 1, len(ctrs))
|
require.Len(t, ctrs, 1)
|
||||||
|
|
||||||
allCtrs, err := state.AllContainers()
|
allCtrs, err := state.AllContainers()
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, 1, len(allCtrs))
|
require.Len(t, allCtrs, 1)
|
||||||
|
|
||||||
testContainersEqual(t, testCtr, ctrs[0])
|
testContainersEqual(t, testCtr, ctrs[0])
|
||||||
testContainersEqual(t, ctrs[0], allCtrs[0])
|
testContainersEqual(t, ctrs[0], allCtrs[0])
|
||||||
@ -2703,7 +2704,7 @@ func TestAddContainerToPodWithAddContainer(t *testing.T) {
|
|||||||
|
|
||||||
ctrs, err := state.PodContainers(testPod)
|
ctrs, err := state.PodContainers(testPod)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, 1, len(ctrs))
|
require.Len(t, ctrs, 1)
|
||||||
|
|
||||||
allCtrs, err := state.AllContainers()
|
allCtrs, err := state.AllContainers()
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
Reference in New Issue
Block a user