Skip to content

Commit

Permalink
test: TestRefineCommand
Browse files Browse the repository at this point in the history
  • Loading branch information
hanchchch committed Mar 21, 2024
1 parent 83f0a89 commit 24b5376
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions suggest/api_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package suggest

import (
"testing"

ollama "github.com/jmorganca/ollama/api"
"github.com/yusufcanb/tlm/config"
)

func TestRefineCommand(t *testing.T) {
con := config.New()
con.LoadOrCreateConfig()

o, _ := ollama.ClientFromEnvironment()
s := New(o)

if s.refineCommand("ls -al") != "ls -al" {
t.Error("no change should be made if the command is already okay")
}

if s.refineCommand("$ ls -al") != "ls -al" {
t.Error("shell prefix should be removed")
}

if s.refineCommand("❯ ls -al") != "ls -al" {
t.Error("shell prefix should be removed")
}

if s.refineCommand(" ls -al") != "ls -al" {
t.Error("leading space should be removed")
}
}

0 comments on commit 24b5376

Please sign in to comment.