Skip to content

Commit

Permalink
virtcontainers: Add additional unit tests for sandbox
Browse files Browse the repository at this point in the history
Add tests for state change, empty string failures for Volumes and
Sockets. Change two function names to accurately reflect tests.

Signed-off-by: Chelsea Mafrica <chelsea.e.mafrica@intel.com>
  • Loading branch information
cmaf committed Jul 24, 2020
1 parent 07a307b commit 0b3cbee
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions src/runtime/virtcontainers/types/sandbox_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,17 @@ func TestSandboxStateRunningStopped(t *testing.T) {
assert.NoError(t, err)
}

func TestSandboxStateReadyPaused(t *testing.T) {
func TestSandboxStateReadyStopped(t *testing.T) {
err := testSandboxStateTransition(t, StateReady, StateStopped)
assert.NoError(t, err)
}

func TestSandboxStatePausedReady(t *testing.T) {
func TestSandboxStateStoppedRunning(t *testing.T) {
err := testSandboxStateTransition(t, StateStopped, StateRunning)
assert.NoError(t, err)
}

func TestSandboxStateStoppedReady(t *testing.T) {
err := testSandboxStateTransition(t, StateStopped, StateReady)
assert.Error(t, err)
}
Expand Down Expand Up @@ -104,6 +109,15 @@ func TestVolumesSetSuccessful(t *testing.T) {
assert.Exactly(t, *volumes, expected)
}

func TestVolumesSetFailingEmptyString(t *testing.T) {
volumes := &Volumes{}

volStr := ""

err := volumes.Set(volStr)
assert.Error(t, err)
}

func TestVolumesSetFailingTooFewArguments(t *testing.T) {
volumes := &Volumes{}

Expand Down Expand Up @@ -174,6 +188,15 @@ func TestSocketsSetSuccessful(t *testing.T) {
assert.Exactly(t, *sockets, expected)
}

func TestSocketsSetFailingEmptyString(t *testing.T) {
sockets := &Sockets{}

sockStr := ""

err := sockets.Set(sockStr)
assert.Error(t, err)
}

func TestSocketsSetFailingWrongArgsAmount(t *testing.T) {
sockets := &Sockets{}

Expand Down

0 comments on commit 0b3cbee

Please sign in to comment.