Files
iris-context/integration/shell/adapter_test.go
T
VERSE 1e04949242 refactor: better project structure (#35)
This project is starting to grow, and I've seen flaws in the initial
project structure design
I think I'll restructure the entire project directory for better
scalability and also cleaner
2026-07-11 16:15:05 +07:00

51 lines
1.0 KiB
Go

package shell
import (
"reflect"
"testing"
)
func TestScanPosixAliases(t *testing.T) {
input := `
alias gca='git commit -a'
alias ta="tmux a -t" # this is a comment
# alias hidden="not found"
alias l='ls' ll='ls -l'
`
expected := map[string]string{
"gca": "git commit -a",
"ta": "tmux a -t",
"l": "ls",
"ll": "ls -l",
}
got := ParseAliases(input)
if !reflect.DeepEqual(got, expected) {
t.Errorf("ScanPosixAliases() = %v; want %v", got, expected)
}
}
func TestSplitAliasTokens(t *testing.T) {
tests := []struct {
name string
input string
expected []string
}{
{"Single", "a='b'", []string{"a='b'"}},
{"Multi", "a='b' c=\"d\"", []string{"a='b'", "c=\"d\""}},
{"With Space", "ta='tmux a -t' l='ls -l'", []string{"ta='tmux a -t'", "l='ls -l'"}},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := SplitAliasTokens(tt.input)
if !reflect.DeepEqual(got, tt.expected) {
t.Errorf("SplitAliasTokens(%q) = %v; want %v", tt.input, got, tt.expected)
}
})
}
}