blob: 8ca43c09db8337e2d263c9f0515ed562e10dc023 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
package tests
import (
"bytes"
"encoding/json"
"fmt"
"github.com/MichaelMure/git-bug/bug"
"testing"
)
func TestOperationPackSerialize(t *testing.T) {
opp := bug.OperationPack{}
opp.Append(createOp)
opp.Append(setTitleOp)
jsonBytes, err := opp.Serialize()
if err != nil {
t.Fatal(err)
}
if len(jsonBytes) == 0 {
t.Fatal("empty json")
}
fmt.Println(prettyPrintJSON(jsonBytes))
}
func prettyPrintJSON(jsonBytes []byte) (string, error) {
var prettyBytes bytes.Buffer
err := json.Indent(&prettyBytes, jsonBytes, "", " ")
if err != nil {
return "", err
}
return prettyBytes.String(), nil
}
|