Skip to content

Commit

Permalink
Update test suites
Browse files Browse the repository at this point in the history
Signed-off-by: Urvashi Mohnani <umohnani@redhat.com>
  • Loading branch information
umohnani8 committed May 9, 2019
1 parent 75d882e commit 3616943
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/container_server_test.go
Expand Up @@ -338,6 +338,7 @@ var _ = t.Describe("ContainerServer", func() {
It("should succeed with removed container", func() {
// Given
mockDirs(testManifest)
createDummyState()
gomock.InOrder(
storeMock.EXPECT().Containers().
Return([]cstorage.Container{{}}, nil),
Expand All @@ -357,6 +358,7 @@ var _ = t.Describe("ContainerServer", func() {
It("should succeed with already added sandbox", func() {
// Given
sut.AddSandbox(mySandbox)
createDummyState()
mockDirs(testManifest)
gomock.InOrder(
storeMock.EXPECT().Containers().
Expand All @@ -374,6 +376,7 @@ var _ = t.Describe("ContainerServer", func() {

It("should fail when storage fails", func() {
// Given
createDummyState()
gomock.InOrder(
storeMock.EXPECT().Containers().Return(nil, t.TestError),
)
Expand All @@ -389,6 +392,7 @@ var _ = t.Describe("ContainerServer", func() {
t.Describe("LoadSandbox", func() {
It("should succeed", func() {
// Given
createDummyState()
mockDirs(testManifest)

// When
Expand All @@ -400,6 +404,7 @@ var _ = t.Describe("ContainerServer", func() {

It("should succeed with invalid network namespace", func() {
// Given
createDummyState()
manifest := bytes.Replace(testManifest,
[]byte(`{"type": "network", "path": "default"}`),
[]byte(`{"type": "", "path": ""},{"type": "network", "path": ""}`), 1,
Expand All @@ -415,6 +420,7 @@ var _ = t.Describe("ContainerServer", func() {

It("should succeed with missing network namespace", func() {
// Given
createDummyState()
manifest := bytes.Replace(testManifest,
[]byte(`{"type": "network", "path": "default"}`),
[]byte(`{}`), 1,
Expand Down Expand Up @@ -655,6 +661,7 @@ var _ = t.Describe("ContainerServer", func() {
t.Describe("LoadContainer", func() {
It("should succeed", func() {
// Given
createDummyState()
sut.AddSandbox(mySandbox)
mockDirs(testManifest)

Expand Down
5 changes: 5 additions & 0 deletions lib/suite_test.go
Expand Up @@ -2,6 +2,7 @@ package lib_test

import (
"context"
"io/ioutil"
"os"
"testing"
"time"
Expand Down Expand Up @@ -166,3 +167,7 @@ func addContainerAndSandbox() {
Expect(sut.CtrIDIndex().Add(containerID)).To(BeNil())
Expect(sut.PodIDIndex().Add(sandboxID)).To(BeNil())
}

func createDummyState() {
ioutil.WriteFile("state.json", []byte("{}"), 0644)
}

0 comments on commit 3616943

Please sign in to comment.