MCPcopy
hub / github.com/perkeep/perkeep / TestJSON

Function TestJSON

pkg/schema/schema_test.go:38–53  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

36const expectedHeader = `{"camliVersion"`
37
38func TestJSON(t *testing.T) {
39 fileName := "schema_test.go"
40 fi, _ := os.Lstat(fileName)
41 m := NewCommonFileMap(fileName, fi)
42 json, err := m.JSON()
43 if err != nil {
44 t.Fatalf("Unexpected error: %v", err)
45 }
46 t.Logf("Got json: [%s]\n", json)
47 // TODO: test it parses back
48
49 if !strings.HasPrefix(json, expectedHeader) {
50 t.Errorf("JSON doesn't start with expected header.")
51 }
52
53}
54
55func TestRegularFile(t *testing.T) {
56 fileName := "schema_test.go"

Callers

nothing calls this directly

Calls 6

NewCommonFileMapFunction · 0.85
LogfMethod · 0.80
HasPrefixMethod · 0.80
LstatMethod · 0.65
FatalfMethod · 0.65
JSONMethod · 0.45

Tested by

no test coverage detected