mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-29 04:04:45 +00:00
virtcontainers: Remove duplicate unit tests
Remove tests from virtcontainers/sandbox_test.go which were moved to virtcontainers/types/sandbox_test.go. Signed-off-by: Chelsea Mafrica <chelsea.e.mafrica@intel.com>
This commit is contained in:
parent
d914f01829
commit
07a307b4b1
@ -169,215 +169,6 @@ func TestCreateSandboxEmptyID(t *testing.T) {
|
||||
defer cleanUp()
|
||||
}
|
||||
|
||||
func testSandboxStateTransition(t *testing.T, state types.StateString, newState types.StateString) error {
|
||||
hConfig := newHypervisorConfig(nil, nil)
|
||||
|
||||
p, err := testCreateSandbox(t, testSandboxID, MockHypervisor, hConfig, NetworkConfig{}, nil, nil)
|
||||
assert.NoError(t, err)
|
||||
defer cleanUp()
|
||||
|
||||
p.state = types.SandboxState{
|
||||
State: state,
|
||||
}
|
||||
|
||||
return p.state.ValidTransition(state, newState)
|
||||
}
|
||||
|
||||
func TestSandboxStateReadyRunning(t *testing.T) {
|
||||
err := testSandboxStateTransition(t, types.StateReady, types.StateRunning)
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
|
||||
func TestSandboxStateRunningPaused(t *testing.T) {
|
||||
err := testSandboxStateTransition(t, types.StateRunning, types.StatePaused)
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
|
||||
func TestSandboxStatePausedRunning(t *testing.T) {
|
||||
err := testSandboxStateTransition(t, types.StatePaused, types.StateRunning)
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
|
||||
func TestSandboxStatePausedStopped(t *testing.T) {
|
||||
err := testSandboxStateTransition(t, types.StatePaused, types.StateStopped)
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
|
||||
func TestSandboxStateRunningStopped(t *testing.T) {
|
||||
err := testSandboxStateTransition(t, types.StateRunning, types.StateStopped)
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
|
||||
func TestSandboxStateReadyPaused(t *testing.T) {
|
||||
err := testSandboxStateTransition(t, types.StateReady, types.StateStopped)
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
|
||||
func TestSandboxStatePausedReady(t *testing.T) {
|
||||
err := testSandboxStateTransition(t, types.StateStopped, types.StateReady)
|
||||
assert.Error(t, err)
|
||||
}
|
||||
|
||||
func testStateValid(t *testing.T, stateStr types.StateString, expected bool) {
|
||||
state := &types.SandboxState{
|
||||
State: stateStr,
|
||||
}
|
||||
|
||||
ok := state.Valid()
|
||||
assert.Equal(t, ok, expected)
|
||||
}
|
||||
|
||||
func TestStateValidSuccessful(t *testing.T) {
|
||||
testStateValid(t, types.StateReady, true)
|
||||
testStateValid(t, types.StateRunning, true)
|
||||
testStateValid(t, types.StatePaused, true)
|
||||
testStateValid(t, types.StateStopped, true)
|
||||
}
|
||||
|
||||
func TestStateValidFailing(t *testing.T) {
|
||||
testStateValid(t, "", false)
|
||||
}
|
||||
|
||||
func TestValidTransitionFailingOldStateMismatch(t *testing.T) {
|
||||
state := &types.SandboxState{
|
||||
State: types.StateReady,
|
||||
}
|
||||
|
||||
err := state.ValidTransition(types.StateRunning, types.StateStopped)
|
||||
assert.Error(t, err)
|
||||
}
|
||||
|
||||
func TestVolumesSetSuccessful(t *testing.T) {
|
||||
volumes := &types.Volumes{}
|
||||
|
||||
volStr := "mountTag1:hostPath1 mountTag2:hostPath2"
|
||||
|
||||
expected := types.Volumes{
|
||||
{
|
||||
MountTag: "mountTag1",
|
||||
HostPath: "hostPath1",
|
||||
},
|
||||
{
|
||||
MountTag: "mountTag2",
|
||||
HostPath: "hostPath2",
|
||||
},
|
||||
}
|
||||
|
||||
err := volumes.Set(volStr)
|
||||
assert.NoError(t, err)
|
||||
assert.Exactly(t, *volumes, expected)
|
||||
}
|
||||
|
||||
func TestVolumesSetFailingTooFewArguments(t *testing.T) {
|
||||
volumes := &types.Volumes{}
|
||||
|
||||
volStr := "mountTag1 mountTag2"
|
||||
|
||||
err := volumes.Set(volStr)
|
||||
assert.Error(t, err)
|
||||
}
|
||||
|
||||
func TestVolumesSetFailingTooManyArguments(t *testing.T) {
|
||||
volumes := &types.Volumes{}
|
||||
|
||||
volStr := "mountTag1:hostPath1:Foo1 mountTag2:hostPath2:Foo2"
|
||||
|
||||
err := volumes.Set(volStr)
|
||||
assert.Error(t, err)
|
||||
}
|
||||
|
||||
func TestVolumesSetFailingVoidArguments(t *testing.T) {
|
||||
volumes := &types.Volumes{}
|
||||
|
||||
volStr := ": : :"
|
||||
|
||||
err := volumes.Set(volStr)
|
||||
assert.Error(t, err)
|
||||
}
|
||||
|
||||
func TestVolumesStringSuccessful(t *testing.T) {
|
||||
volumes := &types.Volumes{
|
||||
{
|
||||
MountTag: "mountTag1",
|
||||
HostPath: "hostPath1",
|
||||
},
|
||||
{
|
||||
MountTag: "mountTag2",
|
||||
HostPath: "hostPath2",
|
||||
},
|
||||
}
|
||||
|
||||
expected := "mountTag1:hostPath1 mountTag2:hostPath2"
|
||||
|
||||
result := volumes.String()
|
||||
assert.Equal(t, result, expected)
|
||||
}
|
||||
|
||||
func TestSocketsSetSuccessful(t *testing.T) {
|
||||
sockets := &types.Sockets{}
|
||||
|
||||
sockStr := "devID1:id1:hostPath1:Name1 devID2:id2:hostPath2:Name2"
|
||||
|
||||
expected := types.Sockets{
|
||||
{
|
||||
DeviceID: "devID1",
|
||||
ID: "id1",
|
||||
HostPath: "hostPath1",
|
||||
Name: "Name1",
|
||||
},
|
||||
{
|
||||
DeviceID: "devID2",
|
||||
ID: "id2",
|
||||
HostPath: "hostPath2",
|
||||
Name: "Name2",
|
||||
},
|
||||
}
|
||||
|
||||
err := sockets.Set(sockStr)
|
||||
assert.NoError(t, err)
|
||||
assert.Exactly(t, *sockets, expected)
|
||||
}
|
||||
|
||||
func TestSocketsSetFailingWrongArgsAmount(t *testing.T) {
|
||||
sockets := &types.Sockets{}
|
||||
|
||||
sockStr := "devID1:id1:hostPath1"
|
||||
|
||||
err := sockets.Set(sockStr)
|
||||
assert.Error(t, err)
|
||||
}
|
||||
|
||||
func TestSocketsSetFailingVoidArguments(t *testing.T) {
|
||||
sockets := &types.Sockets{}
|
||||
|
||||
sockStr := ":::"
|
||||
|
||||
err := sockets.Set(sockStr)
|
||||
assert.Error(t, err)
|
||||
}
|
||||
|
||||
func TestSocketsStringSuccessful(t *testing.T) {
|
||||
sockets := &types.Sockets{
|
||||
{
|
||||
DeviceID: "devID1",
|
||||
ID: "id1",
|
||||
HostPath: "hostPath1",
|
||||
Name: "Name1",
|
||||
},
|
||||
{
|
||||
DeviceID: "devID2",
|
||||
ID: "id2",
|
||||
HostPath: "hostPath2",
|
||||
Name: "Name2",
|
||||
},
|
||||
}
|
||||
|
||||
expected := "devID1:id1:hostPath1:Name1 devID2:id2:hostPath2:Name2"
|
||||
|
||||
result := sockets.String()
|
||||
assert.Equal(t, result, expected)
|
||||
}
|
||||
|
||||
func TestSandboxListSuccessful(t *testing.T) {
|
||||
sandbox := &Sandbox{}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user