From c6f1ed4d5a6b2b55edd2015cdeab3c5f77cc71b7 Mon Sep 17 00:00:00 2001 From: utam0k Date: Sun, 19 Sep 2021 00:31:38 +0900 Subject: [PATCH] add unit test for the `server/sandbox_remove`. Signed-off-by: utam0k --- server/sandbox_remove_test.go | 43 +++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 server/sandbox_remove_test.go diff --git a/server/sandbox_remove_test.go b/server/sandbox_remove_test.go new file mode 100644 index 00000000000..8ef4be35b17 --- /dev/null +++ b/server/sandbox_remove_test.go @@ -0,0 +1,43 @@ +package server_test + +import ( + "github.com/cri-o/cri-o/server/cri/types" + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" + "golang.org/x/net/context" +) + +// The actual test suite +var _ = t.Describe("PodSandboxRemove", func() { + // Prepare the sut + BeforeEach(func() { + beforeEach() + setupSUT() + }) + + AfterEach(afterEach) + + t.Describe("PodSandboxRemove", func() { + It("should fail when sandbox is not created", func() { + // Given + Expect(sut.AddSandbox(testSandbox)).To(BeNil()) + Expect(sut.PodIDIndex().Add(testSandbox.ID())).To(BeNil()) + + // When + err := sut.RemovePodSandbox(context.Background(), + &types.RemovePodSandboxRequest{PodSandboxID: testSandbox.ID()}) + + // Then + Expect(err).NotTo(BeNil()) + }) + + It("should fail with empty sandbox ID", func() { + // When + err := sut.StopPodSandbox(context.Background(), + &types.StopPodSandboxRequest{}) + + // Then + Expect(err).NotTo(BeNil()) + }) + }) +})