ai testing

This commit is contained in:
2026-04-05 23:21:42 +02:00
parent 9cf919b42b
commit 82fc2c9191
8 changed files with 346 additions and 4 deletions

27
internal/utils_test.go Normal file
View File

@@ -0,0 +1,27 @@
package internal
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestExecuteCommandWithMock(t *testing.T) {
// Backup original
originalExecutor := DefaultExecutor
defer func() { DefaultExecutor = originalExecutor }()
// Inject mock
mock := &MockExecutor{
ExecuteFunc: func(options ExecuteOptions, args ...string) (int, string, error) {
assert.Equal(t, "docker", options.Command)
return 0, "mock output", nil
},
}
DefaultExecutor = mock
code, out, err := ExecuteCommand(ExecuteOptions{Command: "docker"}, "info")
assert.NoError(t, err)
assert.Equal(t, 0, code)
assert.Equal(t, "mock output", out)
}