From 60fcfcdcb0e89741528cfc99a94a48f204d48e6b Mon Sep 17 00:00:00 2001 From: Michael Muré Date: Wed, 12 Sep 2018 16:57:04 +0200 Subject: bug: change the OperationPack serialization format for Json See https://github.com/MichaelMure/git-bug/issues/5 for the details of this choice --- tests/operation_pack_test.go | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'tests/operation_pack_test.go') diff --git a/tests/operation_pack_test.go b/tests/operation_pack_test.go index 35b77a8f..62f406a4 100644 --- a/tests/operation_pack_test.go +++ b/tests/operation_pack_test.go @@ -1,30 +1,34 @@ package tests import ( - "github.com/MichaelMure/git-bug/bug" + "encoding/json" + "reflect" "testing" + + "github.com/MichaelMure/git-bug/bug" ) func TestOperationPackSerialize(t *testing.T) { - opp := bug.OperationPack{} + opp := &bug.OperationPack{} opp.Append(createOp) opp.Append(setTitleOp) opp.Append(addCommentOp) + opp.Append(setStatusOp) + opp.Append(labelChangeOp) - data, err := opp.Serialize() - + data, err := json.Marshal(opp) if err != nil { t.Fatal(err) } - if len(data) == 0 { - t.Fatal("empty serialized data") - } - - _, err = bug.ParseOperationPack(data) - + var opp2 *bug.OperationPack + err = json.Unmarshal(data, &opp2) if err != nil { t.Fatal(err) } + + if !reflect.DeepEqual(opp, opp2) { + t.Fatalf("%v and %v are different", opp, opp2) + } } -- cgit