diff options
| author | Paul Buetow <paul@buetow.org> | 2026-03-16 23:01:59 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-03-16 23:01:59 +0200 |
| commit | ed32c7fea5ad0fefccab9c99a51ebdae13b3a2f2 (patch) | |
| tree | 583f793af4287444346ff63d4a448625cc2346c9 /internal/repl/commands_test.go | |
| parent | 57a7b5961037eb565d9cddc324bd0246daff440b (diff) | |
bump version to v0.2.0v0.2.0
- Add REPL mode with vi keybindings
- Add built-in commands (help, clear, quit/exit)
- Add mage repl target
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Diffstat (limited to 'internal/repl/commands_test.go')
| -rw-r--r-- | internal/repl/commands_test.go | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/internal/repl/commands_test.go b/internal/repl/commands_test.go new file mode 100644 index 0000000..7a37579 --- /dev/null +++ b/internal/repl/commands_test.go @@ -0,0 +1,70 @@ +package repl + +import ( + "strings" + "testing" +) + +func TestExecuteCommandHelp(t *testing.T) { + output, err := ExecuteCommand("help") + if err != nil { + t.Fatalf("ExecuteCommand('help') returned error: %v", err) + } + if output == "" { + t.Error("ExecuteCommand('help') returned empty output") + } + if !strings.Contains(output, "PERC") { + t.Errorf("ExecuteCommand('help') output should contain 'PERC', got: %s", output[:50]) + } +} + +func TestExecuteCommandHelpWithSubcommand(t *testing.T) { + output, err := ExecuteCommand("help clear") + if err != nil { + t.Fatalf("ExecuteCommand('help clear') returned error: %v", err) + } + if output == "" { + t.Error("ExecuteCommand('help clear') returned empty output") + } + if !strings.Contains(output, "Clear") { + t.Errorf("ExecuteCommand('help clear') output should contain 'Clear', got: %s", output[:50]) + } +} + +func TestExecuteCommandUnknownCommand(t *testing.T) { + _, err := ExecuteCommand("unknown") + if err == nil { + t.Error("ExecuteCommand('unknown') should return error, got nil") + } + if !strings.Contains(err.Error(), "unknown command") { + t.Errorf("Error should mention 'unknown command', got: %v", err) + } +} + +func TestExecuteCommandClear(t *testing.T) { + _, err := ExecuteCommand("clear") + if err != nil { + t.Fatalf("ExecuteCommand('clear') returned error: %v", err) + } +} + +func TestExecuteCommandQuit(t *testing.T) { + _, err := ExecuteCommand("quit") + if err != nil { + t.Fatalf("ExecuteCommand('quit') returned error: %v", err) + } +} + +func TestExecuteCommandExit(t *testing.T) { + _, err := ExecuteCommand("exit") + if err != nil { + t.Fatalf("ExecuteCommand('exit') returned error: %v", err) + } +} + +func TestExecuteCommandEmpty(t *testing.T) { + _, err := ExecuteCommand("") + if err != nil { + t.Fatalf("ExecuteCommand('') returned error: %v", err) + } +} |
