diff --git a/internal/factsengine/gatherers/commandexecutor.go b/internal/utils/commandexecutor.go similarity index 94% rename from internal/factsengine/gatherers/commandexecutor.go rename to internal/utils/commandexecutor.go index 8b31dd78..d23cee36 100644 --- a/internal/factsengine/gatherers/commandexecutor.go +++ b/internal/utils/commandexecutor.go @@ -1,4 +1,4 @@ -package gatherers +package utils import ( "os/exec" diff --git a/internal/factsengine/gatherers/mocks/CommandExecutor.go b/internal/utils/mocks/CommandExecutor.go similarity index 63% rename from internal/factsengine/gatherers/mocks/CommandExecutor.go rename to internal/utils/mocks/CommandExecutor.go index c79c7d21..cb4b4e16 100644 --- a/internal/factsengine/gatherers/mocks/CommandExecutor.go +++ b/internal/utils/mocks/CommandExecutor.go @@ -1,4 +1,4 @@ -// Code generated by mockery v0.0.0-dev. DO NOT EDIT. +// Code generated by mockery v2.12.3. DO NOT EDIT. package mocks @@ -38,3 +38,18 @@ func (_m *CommandExecutor) Exec(name string, arg ...string) ([]byte, error) { return r0, r1 } + +type NewCommandExecutorT interface { + mock.TestingT + Cleanup(func()) +} + +// NewCommandExecutor creates a new instance of CommandExecutor. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewCommandExecutor(t NewCommandExecutorT) *CommandExecutor { + mock := &CommandExecutor{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +}