返回 DeepSeek-Reasonix
key_windows_test.go
根目录 / internal / pathidentity / key_windows_test.go
1 //go:build windows
2
3 package pathidentity
4
5 import (
6 "fmt"
7 "path/filepath"
8 "strings"
9 "testing"
10
11 "golang.org/x/sys/windows"
12 )
13
14 func TestWindowsIdentityKeyFoldsPerDirectory(t *testing.T) {
15 caseSensitiveParent := filepath.Clean(`C:\Root`)
16 identity := func(path string) string {
17 key, err := windowsIdentityKeyBy(path, func(directory string) (bool, bool, error) {
18 return !strings.EqualFold(filepath.Clean(directory), caseSensitiveParent), true, nil
19 })
20 if err != nil {
21 t.Fatal(err)
22 }
23 return key
24 }
25 upper := identity(`C:\ROOT\Foo\LEAF.jsonl`)
26 lower := identity(`c:\root\foo\leaf.jsonl`)
27 if upper == lower {
28 t.Fatalf("case-sensitive child names collapsed to %q", upper)
29 }
30 if got, want := upper, filepath.Clean(`c:\root\Foo\leaf.jsonl`); got != want {
31 t.Fatalf("segment-aware identity = %q, want %q", got, want)
32 }
33 }
34
35 func TestCaseSensitivityUnsupportedRecognizesWrappedStatus(t *testing.T) {
36 for _, status := range []windows.NTStatus{windows.STATUS_INVALID_INFO_CLASS, windows.STATUS_INVALID_PARAMETER, windows.STATUS_NOT_SUPPORTED} {
37 if !caseSensitivityQueryUnsupported(status) || !caseSensitivityQueryUnsupported(fmt.Errorf("query: %w", status)) {
38 t.Fatalf("unsupported status %v not recognized", status)
39 }
40 }
41 if caseSensitivityQueryUnsupported(nil) || caseSensitivityQueryUnsupported(windows.STATUS_ACCESS_DENIED) {
42 t.Fatal("success or access failure treated as unsupported")
43 }
44 }
45
46 func TestDirectoryCaseInsensitiveQueriesNativeDirectory(t *testing.T) {
47 insensitive, exists, err := directoryCaseInsensitive(t.TempDir())
48 if err != nil {
49 t.Fatalf("query directory case sensitivity: %v", err)
50 }
51 if !exists {
52 t.Fatal("temporary directory should exist")
53 }
54 _ = insensitive
55 }
56
56 lines GO