-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d8add01
commit 800b995
Showing
11 changed files
with
977 additions
and
268 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package executor | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
) | ||
|
||
// mockExecutor implements the necessary methods for testing | ||
type mockExecutor struct { | ||
executeFunc func(ctx context.Context, command string) (string, error) | ||
} | ||
|
||
func (m *mockExecutor) Execute(ctx context.Context, command string) (string, error) { | ||
if m.executeFunc != nil { | ||
return m.executeFunc(ctx, command) | ||
} | ||
return "", nil | ||
} | ||
|
||
func TestExecutor(t *testing.T) { | ||
t.Run("ExecuteCommand", func(t *testing.T) { | ||
expectedOutput := "command output" | ||
executor := &mockExecutor{ | ||
executeFunc: func(ctx context.Context, command string) (string, error) { | ||
return expectedOutput, nil | ||
}, | ||
} | ||
|
||
output, err := executor.Execute(context.Background(), "test command") | ||
if err != nil { | ||
t.Fatalf("Expected no error, got %v", err) | ||
} | ||
|
||
if output != expectedOutput { | ||
t.Errorf("Expected %q, got %q", expectedOutput, output) | ||
} | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.