77 "strings"
88 "testing"
99
10+ "github.com/checkmarx/ast-cli/internal/kicsshutdown"
1011 commonParams "github.com/checkmarx/ast-cli/internal/params"
1112 "github.com/google/uuid"
1213 "github.com/spf13/viper"
@@ -46,6 +47,7 @@ func (m *MockContainerManager) GenerateContainerID() string {
4647 containerName := KicsContainerPrefix + containerID
4748 m .GeneratedContainerIDs = append (m .GeneratedContainerIDs , containerName )
4849 viper .Set (commonParams .KicsContainerNameKey , containerName )
50+ kicsshutdown .SetKicsContainerName (containerName )
4951 return containerName
5052}
5153
@@ -102,6 +104,7 @@ func TestMockContainerManager_GenerateContainerID(t *testing.T) {
102104
103105 // Clear any existing value
104106 viper .Set (commonParams .KicsContainerNameKey , "" )
107+ kicsshutdown .SetKicsContainerName ("" )
105108
106109 containerName := dm .GenerateContainerID ()
107110
@@ -125,6 +128,9 @@ func TestMockContainerManager_GenerateContainerID(t *testing.T) {
125128 if viperValue != containerName {
126129 t .Errorf ("Viper should be set to '%s', got '%s'" , containerName , viperValue )
127130 }
131+ if kicsshutdown .GetKicsContainerName () != containerName {
132+ t .Errorf ("kicsshutdown should be set to '%s', got '%s'" , containerName , kicsshutdown .GetKicsContainerName ())
133+ }
128134
129135 // Test that mock recorded the generated ID
130136 if len (dm .GeneratedContainerIDs ) != 1 {
@@ -164,6 +170,7 @@ func TestMockContainerManager_RunKicsContainer(t *testing.T) {
164170 // Set up test parameters
165171 containerName := "test-container"
166172 viper .Set (commonParams .KicsContainerNameKey , containerName )
173+ kicsshutdown .SetKicsContainerName (containerName )
167174
168175 tests := []struct {
169176 name string
@@ -263,6 +270,9 @@ func TestMockContainerManager_Integration(t *testing.T) {
263270 if viper .GetString (commonParams .KicsContainerNameKey ) != containerName {
264271 t .Error ("Container name should be set in viper after generation" )
265272 }
273+ if kicsshutdown .GetKicsContainerName () != containerName {
274+ t .Error ("Container name should be set in kicsshutdown after generation" )
275+ }
266276
267277 // Test running container
268278 err := dm .RunKicsContainer ("docker" , "/tmp:/path" )
@@ -379,6 +389,7 @@ func TestContainerManager_GenerateContainerID(t *testing.T) {
379389
380390 // Clear any existing value
381391 viper .Set (commonParams .KicsContainerNameKey , "" )
392+ kicsshutdown .SetKicsContainerName ("" )
382393
383394 containerName := cm .GenerateContainerID ()
384395
@@ -402,6 +413,9 @@ func TestContainerManager_GenerateContainerID(t *testing.T) {
402413 if viperValue != containerName {
403414 t .Errorf ("Viper should be set to '%s', got '%s'" , containerName , viperValue )
404415 }
416+ if kicsshutdown .GetKicsContainerName () != containerName {
417+ t .Errorf ("kicsshutdown should be set to '%s', got '%s'" , containerName , kicsshutdown .GetKicsContainerName ())
418+ }
405419
406420 // Test that subsequent calls generate different IDs
407421 containerName2 := cm .GenerateContainerID ()
0 commit comments