MCPcopy Index your code
hub / github.com/jetify-com/devbox / TestFile

Function TestFile

internal/cachehash/hash_test.go:10–35  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

8)
9
10func TestFile(t *testing.T) {
11 dir := t.TempDir()
12
13 ab := filepath.Join(dir, "ab.json")
14 err := os.WriteFile(ab, []byte(`{"a":"\n","b":"\u000A"}`), 0o644)
15 if err != nil {
16 t.Fatal(err)
17 }
18 ba := filepath.Join(dir, "ba.json")
19 err = os.WriteFile(ba, []byte(`{"b":"\n","a":"\u000A"}`), 0o644)
20 if err != nil {
21 t.Fatal(err)
22 }
23
24 abHash, err := File(ab)
25 if err != nil {
26 t.Errorf("got File(ab) error: %v", err)
27 }
28 baHash, err := File(ba)
29 if err != nil {
30 t.Errorf("got File(ba) error: %v", err)
31 }
32 if abHash == baHash {
33 t.Errorf("got (File(%q) = %q) == (File(%q) = %q), want different hashes", ab, abHash, ba, baHash)
34 }
35}
36
37func TestFileNotExist(t *testing.T) {
38 t.TempDir()

Callers

nothing calls this directly

Calls 1

FileFunction · 0.70

Tested by

no test coverage detected