Files
zzet--gortex/internal/hooks/classifycwd_case_test.go
wehub-resource-sync 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
chore: import upstream snapshot with attribution
2026-07-13 12:33:42 +08:00

43 lines
1.4 KiB
Go

package hooks
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/zzet/gortex/internal/daemon"
"github.com/zzet/gortex/internal/pathkey"
)
func forceHooksCaseInsensitive(t *testing.T, v bool) {
t.Helper()
prev := pathkey.CaseInsensitivePaths
pathkey.CaseInsensitivePaths = v
t.Cleanup(func() { pathkey.CaseInsensitivePaths = prev })
}
func TestClassifyCwd_CaseMismatchedExact(t *testing.T) {
forceHooksCaseInsensitive(t, true)
repos := []daemon.TrackedRepoStatus{{Path: "/Users/me/Repo"}}
exact, contained := classifyCwd("/users/me/repo", repos)
require.NotNil(t, exact, "case-variant cwd must match the tracked repo exactly")
assert.Empty(t, contained)
}
func TestClassifyCwd_CaseMismatchedContained(t *testing.T) {
forceHooksCaseInsensitive(t, true)
repos := []daemon.TrackedRepoStatus{{Path: "/Users/me/Workspace/Repo"}}
exact, contained := classifyCwd("/users/me/workspace", repos)
assert.Nil(t, exact)
require.Len(t, contained, 1, "a repo under a case-variant workspace cwd must be contained")
}
func TestClassifyCwd_CaseSensitiveNoMatch(t *testing.T) {
forceHooksCaseInsensitive(t, false)
repos := []daemon.TrackedRepoStatus{{Path: "/Users/me/Repo"}}
exact, contained := classifyCwd("/users/me/repo", repos)
assert.Nil(t, exact, "case-sensitive: byte-different cwd must not match")
assert.Empty(t, contained)
}