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

Function TestJSONFile

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

Source from the content-addressed store, hash-verified

77}
78
79func TestJSONFile(t *testing.T) {
80 dir := t.TempDir()
81
82 compact := filepath.Join(dir, "compact.json")
83 err := os.WriteFile(compact, []byte(`{"key":"value"}`), 0o644)
84 if err != nil {
85 t.Fatal(err)
86 }
87 space := filepath.Join(dir, "space.json")
88 err = os.WriteFile(space, []byte(`{ "key": "value" }`), 0o644)
89 if err != nil {
90 t.Fatal(err)
91 }
92
93 compactHash, err := JSONFile(compact)
94 if err != nil {
95 t.Errorf("got JSONFile(ab) error: %v", err)
96 }
97 spaceHash, err := JSONFile(space)
98 if err != nil {
99 t.Errorf("got JSONFile(ba) error: %v", err)
100 }
101 if compactHash != spaceHash {
102 t.Errorf("got (JSONFile(%q) = %q) != (JSONFile(%q) = %q), want equal hashes", compact, compactHash, space, spaceHash)
103 }
104}
105
106func TestJSONFileNotExist(t *testing.T) {
107 t.TempDir()

Callers

nothing calls this directly

Calls 1

JSONFileFunction · 0.85

Tested by

no test coverage detected