Skip to content

Commit aad475f

Browse files
committed
Tests: Fix ContainerServer.New tests when crio is installed
Skip InternalRepair by simulating a clean shutdown. Signed-off-by: Andreas Karis <[email protected]> Reported-at: #9389
1 parent 44e86da commit aad475f

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

internal/lib/container_server_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ var _ = t.Describe("ContainerServer", func() {
3838
config.HooksDir = []string{}
3939
// so we have permission to make a directory within it
4040
config.ContainerAttachSocketDir = t.MustTempDir("crio")
41+
// Simulate a clean shutdown. Otherwise, when running tests as root on
42+
// a system where cri-o is already installed, we hit non-mocked functions
43+
// in lib.New internal/lib/container_server.go in if condition
44+
// `if config.InternalRepair && ShutdownWasUnclean(config)`.
45+
config.CleanShutdownFile = t.MustTempFile("clean.shutdown")
4146

4247
// Specify mocks
4348
gomock.InOrder(

internal/lib/suite_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,11 @@ func beforeEach() {
145145
config.HooksDir = []string{}
146146
// so we have permission to make a directory within it
147147
config.ContainerAttachSocketDir = t.MustTempDir("crio")
148+
// Simulate a clean shutdown. Otherwise, when running tests as root on
149+
// a system where cri-o is already installed, we hit non-mocked functions
150+
// in lib.New internal/lib/container_server.go in if condition
151+
// `if config.InternalRepair && ShutdownWasUnclean(config)`.
152+
config.CleanShutdownFile = t.MustTempFile("clean.shutdown")
148153

149154
gomock.InOrder(
150155
libMock.EXPECT().GetStore().Return(storeMock, nil),

0 commit comments

Comments
 (0)