-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from hanchchch/main
Trim shell prefix
- Loading branch information
Showing
2 changed files
with
55 additions
and
3 deletions.
There are no files selected for viewing
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,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") | ||
} | ||
} |