Resolve entered command routes to canonical paths

This commit is contained in:
2026-10-19 17:37:59 +00:00
parent 6ea8c4dd3f
commit 58b71c390f
8 changed files with 399 additions and 5 deletions

View File

@@ -0,0 +1,28 @@
package alias
import (
"reflect"
"testing"
"gitea.maximumdirect.net/eric/CommandKit/internal/commandpath"
)
func TestResolveWithProvenanceCarriesInputOriginsThroughChains(t *testing.T) {
resolver, err := NewResolver([]Mapping{
{Source: commandpath.Path{"collections"}, Target: commandpath.Path{"list", "collections"}},
{Source: commandpath.Path{"list", "collections"}, Target: commandpath.Path{"promptkit", "list", "collections"}},
})
if err != nil {
t.Fatal(err)
}
path := commandpath.Path{"collections", "--format", "yaml"}
gotPath, gotOrigins := resolver.ResolveWithProvenance(path)
if want := (commandpath.Path{"promptkit", "list", "collections", "--format", "yaml"}); !reflect.DeepEqual(gotPath, want) {
t.Fatalf("resolved path = %v, want %v", gotPath, want)
}
wantOrigins := [][]int{{0}, {0}, {0}, {1}, {2}}
if !reflect.DeepEqual(gotOrigins, wantOrigins) {
t.Fatalf("origins = %v, want %v", gotOrigins, wantOrigins)
}
}