diff options
Diffstat (limited to 'internal/extract/tools_test.go')
| -rw-r--r-- | internal/extract/tools_test.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/internal/extract/tools_test.go b/internal/extract/tools_test.go index 4a03f1b..b481e8a 100644 --- a/internal/extract/tools_test.go +++ b/internal/extract/tools_test.go @@ -237,3 +237,27 @@ func TestMaxReadCapsToolOutput(t *testing.T) { t.Fatalf("got %v, want ErrTooLarge (max-read 1024 should have capped a 200000-byte tool output)", err) } } + +// TestFingerprintFollowsTools: the fingerprint changes when a tool is +// installed or replaced, and not otherwise. +func TestFingerprintFollowsTools(t *testing.T) { + bin := t.TempDir() + none := newWithPath(bin).Fingerprint() + if none != newWithPath(bin).Fingerprint() { + t.Fatal("fingerprint not stable") + } + tool := filepath.Join(bin, "pdftotext") + if err := os.WriteFile(tool, []byte("#!/bin/sh\n"), 0o755); err != nil { + t.Fatal(err) + } + installed := newWithPath(bin).Fingerprint() + if installed == none { + t.Error("installing pdftotext did not change the fingerprint") + } + if err := os.WriteFile(tool, []byte("#!/bin/sh\nexit 0\n"), 0o755); err != nil { + t.Fatal(err) + } + if newWithPath(bin).Fingerprint() == installed { + t.Error("replacing pdftotext did not change the fingerprint") + } +} |
