Skip to content

Commit 8778fff

Browse files
committed
prettyprint json data
Signed-off-by: Doug Davis <duglin@gmail.com>
1 parent b295461 commit 8778fff

2 files changed

Lines changed: 20 additions & 9 deletions

File tree

registry/resource.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -909,7 +909,7 @@ func (r *Resource) UpsertVersionWithObject(id string, obj Object, addType AddTyp
909909
buf := []byte(nil)
910910
switch reflect.ValueOf(data).Kind() {
911911
case reflect.Float64, reflect.Map, reflect.Slice, reflect.Bool:
912-
buf, err = json.Marshal(data)
912+
buf, err = json.MarshalIndent(data, "", " ")
913913
if err != nil {
914914
return nil, false, err
915915
}

tests/http2_test.go

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -951,11 +951,13 @@ func TestHTTPContent(t *testing.T) {
951951
"xRegistry-versionsurl:http://localhost:8181/dirs/d1/files/f1/versions",
952952
"xRegistry-versionscount:1",
953953
"Content-Type:application/json",
954-
"Content-Length:13",
954+
"Content-Length:18",
955955
"Content-Location:http://localhost:8181/dirs/d1/files/f1/versions/1",
956956
"Content-Disposition:f1",
957957
},
958-
ResBody: `{"foo":"bar"}`,
958+
ResBody: `{
959+
"foo": "bar"
960+
}`,
959961
})
960962
xHTTP(t, reg, "GET", "/dirs/d1/files/f1$details?inline=file", "", 200, `{
961963
"fileid": "f1",
@@ -1022,11 +1024,15 @@ func TestHTTPContent(t *testing.T) {
10221024
"xRegistry-versionsurl:http://localhost:8181/dirs/d1/files/f1/versions",
10231025
"xRegistry-versionscount:1",
10241026
"Content-Type:application/json",
1025-
"Content-Length:16",
1027+
"Content-Length:26",
10261028
"Content-Location:http://localhost:8181/dirs/d1/files/f1/versions/1",
10271029
"Content-Disposition:f1",
10281030
},
1029-
ResBody: `["hello",null,5]`,
1031+
ResBody: `[
1032+
"hello",
1033+
null,
1034+
5
1035+
]`,
10301036
})
10311037
xHTTP(t, reg, "GET", "/dirs/d1/files/f1$details?inline=file", "", 200, `{
10321038
"fileid": "f1",
@@ -1513,11 +1519,13 @@ func TestHTTPContent(t *testing.T) {
15131519
"xRegistry-versionsurl:http://localhost:8181/dirs/d1/files/f12/versions",
15141520
"xRegistry-versionscount:1",
15151521
"Content-Type:application/json",
1516-
"Content-Length:13",
1522+
"Content-Length:18",
15171523
"Content-Location:http://localhost:8181/dirs/d1/files/f12/versions/1",
15181524
"Content-Disposition:f12",
15191525
},
1520-
ResBody: `{"foo":"bar"}`,
1526+
ResBody: `{
1527+
"foo": "bar"
1528+
}`,
15211529
})
15221530

15231531
// New implied json - numeric
@@ -1615,11 +1623,14 @@ func TestHTTPContent(t *testing.T) {
16151623
"xRegistry-versionsurl:http://localhost:8181/dirs/d1/files/f14/versions",
16161624
"xRegistry-versionscount:1",
16171625
"Content-Type:application/json",
1618-
"Content-Length:7",
1626+
"Content-Length:14",
16191627
"Content-Location:http://localhost:8181/dirs/d1/files/f14/versions/1",
16201628
"Content-Disposition:f14",
16211629
},
1622-
ResBody: `[123,0]`,
1630+
ResBody: `[
1631+
123,
1632+
0
1633+
]`,
16231634
})
16241635

16251636
// New implied json - bool

0 commit comments

Comments
 (0)