diff options
author | Michael Muré <batolettre@gmail.com> | 2021-01-03 23:59:25 +0100 |
---|---|---|
committer | Michael Muré <batolettre@gmail.com> | 2021-02-14 12:19:00 +0100 |
commit | 8d63c983c982f93cc48d3996d6bd097ddeeb327f (patch) | |
tree | 94d85594e11965f9780df53a5c0c2b2550c02184 /entity/dag/operation_pack_test.go | |
parent | 4ef92efeb905102d37b81fafa0ac2173594ef30a (diff) | |
download | git-bug-8d63c983c982f93cc48d3996d6bd097ddeeb327f.tar.gz |
WIP
Diffstat (limited to 'entity/dag/operation_pack_test.go')
-rw-r--r-- | entity/dag/operation_pack_test.go | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/entity/dag/operation_pack_test.go b/entity/dag/operation_pack_test.go new file mode 100644 index 00000000..ad2a9859 --- /dev/null +++ b/entity/dag/operation_pack_test.go @@ -0,0 +1,44 @@ +package dag + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +func TestOperationPackReadWrite(t *testing.T) { + repo, id1, _, def := makeTestContext() + + opp := &operationPack{ + Author: id1, + Operations: []Operation{ + newOp1(id1, "foo"), + newOp2(id1, "bar"), + }, + CreateTime: 123, + EditTime: 456, + } + + commitHash, err := opp.Write(def, repo) + require.NoError(t, err) + + commit, err := repo.ReadCommit(commitHash) + require.NoError(t, err) + + opp2, err := readOperationPack(def, repo, commit) + require.NoError(t, err) + + require.Equal(t, opp, opp2) + + // make sure we get the same Id with the same data + opp3 := &operationPack{ + Author: id1, + Operations: []Operation{ + newOp1(id1, "foo"), + newOp2(id1, "bar"), + }, + CreateTime: 123, + EditTime: 456, + } + require.Equal(t, opp.Id(), opp3.Id()) +} |