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

Function TestJSON

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

Source from the content-addressed store, hash-verified

46}
47
48func TestJSON(t *testing.T) {
49 a := struct{ A, B string }{"a", "b"}
50 aHash, err := JSON(a)
51 if err != nil {
52 t.Errorf("got JSON(%#q) error: %v", a, err)
53 }
54 if aHash == "" {
55 t.Errorf(`got JSON(%#q) == ""`, a)
56 }
57
58 b := map[string]string{"A": "a", "B": "b"}
59 bHash, err := JSON(b)
60 if err != nil {
61 t.Errorf("got JSON(%#q) error: %v", b, err)
62 }
63 if bHash == "" {
64 t.Errorf(`got JSON(%#q) == ""`, b)
65 }
66 if aHash != bHash {
67 t.Errorf("got (JSON(%#q) = %q) != (JSON(%#q) = %q), want equal hashes", a, aHash, b, bHash)
68 }
69}
70
71func TestJSONUnsupportedType(t *testing.T) {
72 j := struct{ C chan int }{}

Callers

nothing calls this directly

Calls 1

JSONFunction · 0.85

Tested by

no test coverage detected