(t *testing.T)
| 77 | } |
| 78 | |
| 79 | func 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 | |
| 106 | func TestJSONFileNotExist(t *testing.T) { |
| 107 | t.TempDir() |
nothing calls this directly
no test coverage detected