diff options
Diffstat (limited to 'tests/operation_pack_test.go')
-rw-r--r-- | tests/operation_pack_test.go | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/operation_pack_test.go b/tests/operation_pack_test.go new file mode 100644 index 00000000..8ca43c09 --- /dev/null +++ b/tests/operation_pack_test.go @@ -0,0 +1,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 +} |