| 1 | package gitguard |
| 2 | |
| 3 | import ( |
| 4 | "os" |
| 5 | "path/filepath" |
| 6 | "testing" |
| 7 | ) |
| 8 | |
| 9 | func TestWindowsMetadataHardLinkIsDetected(t *testing.T) { |
| 10 | dir := t.TempDir() |
| 11 | config := filepath.Join(dir, "config") |
| 12 | if err := os.WriteFile(config, []byte("metadata"), 0600); err != nil { |
| 13 | t.Fatal(err) |
| 14 | } |
| 15 | if linked(config) { |
| 16 | t.Fatal("single link reported as shared metadata") |
| 17 | } |
| 18 | if err := os.Link(config, filepath.Join(dir, "editable-alias")); err != nil { |
| 19 | t.Fatal(err) |
| 20 | } |
| 21 | if !linked(config) { |
| 22 | t.Fatal("writable NTFS alias of metadata was not detected") |
| 23 | } |
| 24 | } |