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

Commit d889e9c

Browse files
author
Chelsea Mafrica
committed
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 <chelsea.e.mafrica@intel.com>
1 parent 345d0c2 commit d889e9c

1 file changed

Lines changed: 25 additions & 2 deletions

File tree

virtcontainers/types/sandbox_test.go

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,17 @@ func TestSandboxStateRunningStopped(t *testing.T) {
4444
assert.NoError(t, err)
4545
}
4646

47-
func TestSandboxStateReadyPaused(t *testing.T) {
47+
func TestSandboxStateReadyStopped(t *testing.T) {
4848
err := testSandboxStateTransition(t, StateReady, StateStopped)
4949
assert.NoError(t, err)
5050
}
5151

52-
func TestSandboxStatePausedReady(t *testing.T) {
52+
func TestSandboxStateStoppedRunning(t *testing.T) {
53+
err := testSandboxStateTransition(t, StateStopped, StateRunning)
54+
assert.NoError(t, err)
55+
}
56+
57+
func TestSandboxStateStoppedReady(t *testing.T) {
5358
err := testSandboxStateTransition(t, StateStopped, StateReady)
5459
assert.Error(t, err)
5560
}
@@ -104,6 +109,15 @@ func TestVolumesSetSuccessful(t *testing.T) {
104109
assert.Exactly(t, *volumes, expected)
105110
}
106111

112+
func TestVolumesSetFailingEmptyString(t *testing.T) {
113+
volumes := &Volumes{}
114+
115+
volStr := ""
116+
117+
err := volumes.Set(volStr)
118+
assert.Error(t, err)
119+
}
120+
107121
func TestVolumesSetFailingTooFewArguments(t *testing.T) {
108122
volumes := &Volumes{}
109123

@@ -174,6 +188,15 @@ func TestSocketsSetSuccessful(t *testing.T) {
174188
assert.Exactly(t, *sockets, expected)
175189
}
176190

191+
func TestSocketsSetFailingEmptyString(t *testing.T) {
192+
sockets := &Sockets{}
193+
194+
sockStr := ""
195+
196+
err := sockets.Set(sockStr)
197+
assert.Error(t, err)
198+
}
199+
177200
func TestSocketsSetFailingWrongArgsAmount(t *testing.T) {
178201
sockets := &Sockets{}
179202

0 commit comments

Comments
 (0)