@@ -20,8 +20,8 @@ func TestHooksPreCommitFullIntegration(t *testing.T) {
2020 execCmd (t , tmpDir , "git" , "init" )
2121
2222 // Install pre-commit hook locally
23- output := executeCmdNilAssertion (t , "hooks" , "pre-commit" , "secrets-install-git-hook" )
24- assert .Contains (t , output , "pre-commit installed successfully" )
23+ output := executeCmdNilAssertion (t , "Installing pre-commit hook" , " hooks" , "pre-commit" , "secrets-install-git-hook" )
24+ assert .Contains (t , output . String () , "pre-commit installed successfully" )
2525
2626 // Verify hook installation
2727 hookPath := filepath .Join (tmpDir , ".git" , "hooks" , "pre-commit" )
@@ -47,16 +47,16 @@ ANOTHER MOCK SECRET`
4747 assert .NotEmpty (t , resultIds , "Should detect result IDs" )
4848
4949 // Ignore detected secrets by ID
50- output = executeCmdNilAssertion (t , "hooks" , "pre-commit" , "secrets-ignore" , "--resultIds" , strings .Join (resultIds , "," ))
51- assert .Contains (t , output , "Added new IDs to .checkmarx_ignore" )
50+ output = executeCmdNilAssertion (t , "Ignoring detected secrets" , " hooks" , "pre-commit" , "secrets-ignore" , "--resultIds" , strings .Join (resultIds , "," ))
51+ assert .Contains (t , output . String () , "Added new IDs to .checkmarx_ignore" )
5252
5353 // Run secrets scan again (expect success after ignoring)
54- output = executeCmdNilAssertion (t , "hooks" , "pre-commit" , "secrets-scan" )
55- assert .Contains (t , output , "No secrets detected" )
54+ output = executeCmdNilAssertion (t , "Running secrets scan after ignoring" , " hooks" , "pre-commit" , "secrets-scan" )
55+ assert .Contains (t , output . String () , "No secrets detected" )
5656
5757 // Uninstall pre-commit hook
58- output = executeCmdNilAssertion (t , "hooks" , "pre-commit" , "secrets-uninstall-git-hook" )
59- assert .Contains (t , output , "pre-commit hook uninstalled successfully" )
58+ output = executeCmdNilAssertion (t , "Uninstalling pre-commit hook" , " hooks" , "pre-commit" , "secrets-uninstall-git-hook" )
59+ assert .Contains (t , output . String () , "pre-commit hook uninstalled successfully" )
6060 assert .NoFileExists (t , hookPath , "Hook should be removed after uninstall" )
6161}
6262
@@ -68,21 +68,6 @@ func execCmd(t *testing.T, dir string, name string, args ...string) {
6868 assert .NoError (t , err , "Failed command %s: %s" , strings .Join (cmd .Args , " " ), string (output ))
6969}
7070
71- func executeCmdNilAssertion (t * testing.T , args ... string ) string {
72- err , output := executeCommand (t , args ... )
73- assert .NoError (t , err , "Command should succeed: %s" , strings .Join (args , " " ))
74- return output .String ()
75- }
76-
77- func executeCommand (t * testing.T , args ... string ) (error , * strings.Builder ) {
78- cmd := exec .Command ("cx" , args ... )
79- var output strings.Builder
80- cmd .Stdout = & output
81- cmd .Stderr = & output
82- err := cmd .Run ()
83- return err , & output
84- }
85-
8671func parseResultIDs (output string ) []string {
8772 // Mock parsing function: Extract IDs from output.
8873 // Replace with real parsing logic based on actual scan output format
0 commit comments