Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove pretty-printing #202

Merged
merged 4 commits into from
Jul 16, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions codec/dagjson/multicodec.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func Encode(n ipld.Node, w io.Writer) error {
// (There's not really any fastpaths of note for json.)
// Write another function if you need to tune encoding options about whitespace.
return Marshal(n, json.NewEncoder(w, json.EncodeOptions{
Line: []byte{'\n'},
Indent: []byte{'\t'},
Line: nil,
Indent: nil,
rvagg marked this conversation as resolved.
Show resolved Hide resolved
}), true)
}
21 changes: 2 additions & 19 deletions codec/dagjson/roundtripBytes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,7 @@ var byteNode = fluent.MustBuildMap(basicnode.Prototype__Map{}, 4, func(na fluent
na.AssembleEntry("plain").AssignString("olde string")
na.AssembleEntry("bytes").AssignBytes([]byte("deadbeef"))
})
var byteSerial = `{
"plain": "olde string",
"bytes": {
"/": {
"bytes": "ZGVhZGJlZWY="
}
}
}
`
var byteSerial = `{"plain":"olde string","bytes":{"/":{"bytes":"ZGVhZGJlZWY="}}}`

func TestRoundtripBytes(t *testing.T) {
t.Run("encoding", func(t *testing.T) {
Expand All @@ -46,16 +38,7 @@ var encapsulatedNode = fluent.MustBuildMap(basicnode.Prototype__Map{}, 1, func(n
sa.AssembleEntry("bytes").AssignBytes([]byte("deadbeef"))
})
})
var encapsulatedSerial = `{
"/": {
"bytes": {
"/": {
"bytes": "ZGVhZGJlZWY="
}
}
}
}
`
var encapsulatedSerial = `{"/":{"bytes":{"/":{"bytes":"ZGVhZGJlZWY="}}}}`

func TestEncapsulatedBytes(t *testing.T) {
t.Run("encoding", func(t *testing.T) {
Expand Down
18 changes: 1 addition & 17 deletions codec/dagjson/roundtrip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,7 @@ var n = fluent.MustBuildMap(basicnode.Prototype__Map{}, 4, func(na fluent.MapAss
})
})
})
var serial = `{
"plain": "olde string",
"map": {
"one": 1,
"two": 2
},
"list": [
"three",
"four"
],
"nested": {
"deeper": [
"things"
]
}
}
`
var serial = `{"plain":"olde string","map":{"one":1,"two":2},"list":["three","four"],"nested":{"deeper":["things"]}}`

func TestRoundtrip(t *testing.T) {
t.Run("encoding", func(t *testing.T) {
Expand Down
5 changes: 1 addition & 4 deletions examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ func ExampleCreateDataAndMarshal() {
dagjson.Encode(n, os.Stdout)

// Output:
// {
// "hey": "it works!",
// "yes": true
// }
// {"hey":"it works!","yes":true}
}

func ExampleUnmarshalData() {
Expand Down
13 changes: 1 addition & 12 deletions fluent/qp/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,5 @@ func Example() {
dagjson.Encode(n, os.Stdout)

// Output:
// {
// "some key": "some value",
// "another key": "another value",
// "nested map": {
// "deeper entries": "deeper values",
// "more deeper entries": "more deeper values"
// },
// "nested list": [
// 1,
// 2
// ]
// }
// {"some key":"some value","another key":"another value","nested map":{"deeper entries":"deeper values","more deeper entries":"more deeper values"},"nested list":[1,2]}
}
2 changes: 1 addition & 1 deletion traversal/focus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ func TestFocusedTransformWithLinks(t *testing.T) {
Wish(t, progress.Path.String(), ShouldEqual, "linkedMap/nested/nonlink")
Wish(t, must.String(prev), ShouldEqual, "zoo")
Wish(t, progress.LastBlock.Path.String(), ShouldEqual, "linkedMap")
Wish(t, progress.LastBlock.Link.String(), ShouldEqual, "baguqeeyevmbz3ga")
Wish(t, progress.LastBlock.Link.String(), ShouldEqual, "baguqeeye2opztzy")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty uncomfortable about changing this without verifying the block encodes to this CID, but the fixture is complicated enough that I'm not keen to reconstruct it for a one-off verification unless this arises out of some previously constructed fixture.

nb := prev.Prototype().NewBuilder()
nb.AssignString("new string!")
return nb.Build(), nil
Expand Down