From d889e9cfbeef30a63cb499ce64cac474ef839bd2 Mon Sep 17 00:00:00 2001 From: Chelsea Mafrica Date: Fri, 24 Jul 2020 02:50:42 +0000 Subject: [PATCH] virtcontainers: Add additional unit tests for sandbox 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 --- virtcontainers/types/sandbox_test.go | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/virtcontainers/types/sandbox_test.go b/virtcontainers/types/sandbox_test.go index 875eee1a13..05075e4495 100644 --- a/virtcontainers/types/sandbox_test.go +++ b/virtcontainers/types/sandbox_test.go @@ -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) } @@ -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{} @@ -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{}