a06f331eb8
CI / benchmark (push) Has been skipped
install-script / posix-syntax (push) Successful in 6m1s
CI / build-onnx (push) Failing after 6m43s
init-smoke / dry-run (push) Failing after 15m57s
security / govulncheck (push) Has been cancelled
security / trivy-fs (push) Has been cancelled
CI / test (1.26, ubuntu-latest) (push) Has been cancelled
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
CI / test (1.26, macos-latest) (push) Has been cancelled
CI / build-windows (push) Has been cancelled
CI / lint (push) Has been cancelled
install-script / powershell-syntax (push) Has been cancelled
install-script / install (macos-14) (push) Has been cancelled
install-script / install (ubuntu-latest) (push) Has been cancelled
44 lines
1.3 KiB
Go
44 lines
1.3 KiB
Go
package main
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/zzet/gortex/internal/config"
|
|
)
|
|
|
|
func TestMatchRepo_CaseVariantAbsPath(t *testing.T) {
|
|
forceCaseInsensitivePaths(t, true)
|
|
repos := []config.RepoEntry{
|
|
{Name: "alpha", Path: "/Users/me/Projects/Alpha"},
|
|
{Name: "beta", Path: "/Users/me/Projects/Beta"},
|
|
}
|
|
i, err := matchRepo(repos, "/users/me/projects/alpha")
|
|
require.NoError(t, err)
|
|
assert.Equal(t, 0, i, "case-variant abs path must resolve to the right repo")
|
|
}
|
|
|
|
func TestMatchRepo_CaseSensitiveRejectsVariant(t *testing.T) {
|
|
forceCaseInsensitivePaths(t, false)
|
|
repos := []config.RepoEntry{{Name: "alpha", Path: "/Users/me/Projects/Alpha"}}
|
|
_, err := matchRepo(repos, "/users/me/projects/alpha")
|
|
require.Error(t, err, "case-sensitive: byte-different abs path must not match")
|
|
}
|
|
|
|
func TestMatchRepo_NameMatch(t *testing.T) {
|
|
repos := []config.RepoEntry{{Name: "alpha", Path: "/Users/me/Projects/Alpha"}}
|
|
i, err := matchRepo(repos, "alpha")
|
|
require.NoError(t, err)
|
|
assert.Equal(t, 0, i)
|
|
}
|
|
|
|
func TestMatchRepo_SuffixMatch(t *testing.T) {
|
|
// Exercises the separator-aware suffix fallback (was a hardcoded "/").
|
|
repos := []config.RepoEntry{{Name: "x", Path: "/Users/x/code/work/tuck-api"}}
|
|
i, err := matchRepo(repos, "tuck-api")
|
|
require.NoError(t, err)
|
|
assert.Equal(t, 0, i)
|
|
}
|