From b04800c6d7d40b037d6345a622d79d2f40feb0f2 Mon Sep 17 00:00:00 2001 From: Derek Su Date: Tue, 19 Nov 2024 12:08:37 +0800 Subject: [PATCH] WIP Signed-off-by: Derek Su --- pkg/spdk/engine_test.go | 46 +++++++++++++++++++++++++++++++++++------ 1 file changed, 40 insertions(+), 6 deletions(-) diff --git a/pkg/spdk/engine_test.go b/pkg/spdk/engine_test.go index 25d0bbf1..256f94bf 100644 --- a/pkg/spdk/engine_test.go +++ b/pkg/spdk/engine_test.go @@ -171,11 +171,11 @@ func (s *TestSuite) TestIsNewEngine(c *C) { func (s *TestSuite) TestReleaseTargetAndStandbyTargetPorts(c *C) { testCases := []struct { - name string - engine *Engine - expectedTargetPortRequired bool - expectedStandbyPortRequired bool - expectedError error + name string + engine *Engine + expectedTargetPort int32 + expectedStandbyTargetPort int32 + expectedError error }{ { name: "Release both target and standby target ports", @@ -183,7 +183,39 @@ func (s *TestSuite) TestReleaseTargetAndStandbyTargetPorts(c *C) { TargetPort: 2000, StandbyTargetPort: 2005, }, - expectedError: nil, + expectedTargetPort: 0, + expectedStandbyTargetPort: 0, + expectedError: nil, + }, + { + name: "Release target port only but standby target port is not set", + engine: &Engine{ + TargetPort: 2000, + StandbyTargetPort: 0, + }, + expectedTargetPort: 0, + expectedStandbyTargetPort: 0, + expectedError: nil, + }, + { + name: "Release target port only but standby target port is not set", + engine: &Engine{ + TargetPort: 2000, + StandbyTargetPort: 2000, + }, + expectedTargetPort: 0, + expectedStandbyTargetPort: 0, + expectedError: nil, + }, + { + name: "Release snapshot target port only", + engine: &Engine{ + TargetPort: 0, + StandbyTargetPort: 2000, + }, + expectedTargetPort: 0, + expectedStandbyTargetPort: 0, + expectedError: nil, }, } @@ -195,5 +227,7 @@ func (s *TestSuite) TestReleaseTargetAndStandbyTargetPorts(c *C) { err = testCase.engine.releaseTargetAndStandbyTargetPorts(bitmap) c.Assert(err, DeepEquals, testCase.expectedError, Commentf("Test case '%s': unexpected error result", testCase.name)) + c.Assert(testCase.engine.TargetPort, Equals, testCase.expectedTargetPort, Commentf("Test case '%s': unexpected target port", testCase.name)) + c.Assert(testCase.engine.StandbyTargetPort, Equals, testCase.expectedStandbyTargetPort, Commentf("Test case '%s': unexpected standby target port", testCase.name)) } }