diff options
| author | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-09-14 15:16:55 +0200 |
|---|---|---|
| committer | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-09-14 15:16:55 +0200 |
| commit | 0b5d0eb92c5be2f0ddb2fa73990f31e5654e57fe (patch) | |
| tree | 358e331945b8206ed4a72703e3aedfe8ea7cdcdb /internal/scan/scan_test.go | |
| parent | 1d3f2d1e4c59867024470d3444e12698b7ebb22e (diff) | |
| download | krino-0.0.5.tar.gz krino-0.0.5.zip | |
krino: 0.0.5 — keyword cache, t and d in reviewv0.0.5
Diffstat (limited to 'internal/scan/scan_test.go')
| -rw-r--r-- | internal/scan/scan_test.go | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/internal/scan/scan_test.go b/internal/scan/scan_test.go index a245893..e9aeb73 100644 --- a/internal/scan/scan_test.go +++ b/internal/scan/scan_test.go @@ -293,3 +293,29 @@ func TestTooBig(t *testing.T) { t.Errorf("MaxSize 0 skipped files: %v", skipped(r)) } } + +// TestFilesCarryInode: a walked file carries its device and inode, which a +// rename keeps. +func TestFilesCarryInode(t *testing.T) { + root := tree(t) + p := filepath.Join(root, "a.txt") + if err := os.WriteFile(p, []byte("x"), 0o644); err != nil { + t.Fatal(err) + } + old := now.Add(-time.Hour) + os.Chtimes(p, old, old) + first, err := Walk(root, Options{Now: now}) + if err != nil || len(first.Files) != 1 { + t.Fatalf("walk: %v %+v", err, first) + } + if first.Files[0].Ino == 0 { + t.Fatal("no inode on a unix filesystem") + } + if err := os.Rename(p, filepath.Join(root, "b.txt")); err != nil { + t.Fatal(err) + } + second, _ := Walk(root, Options{Now: now}) + if len(second.Files) != 1 || second.Files[0].Ino != first.Files[0].Ino || second.Files[0].Dev != first.Files[0].Dev { + t.Errorf("rename changed the identity: %+v then %+v", first.Files[0], second.Files) + } +} |
