Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

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 <[email protected]>
  • Loading branch information
Chelsea Mafrica committed Jul 24, 2020
1 parent 345d0c2 commit d889e9c
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions 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 d889e9c

Please sign in to comment.