aboutsummaryrefslogtreecommitdiffstats
path: root/entity/dag/operation_pack_test.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2021-02-20 15:48:44 +0100
committerMichael Muré <batolettre@gmail.com>2021-03-14 18:41:22 +0100
commit214abe4dea1984086e45d1399538fb12aa010642 (patch)
tree6536f3ff7304e6b6abdd88728b391b726a471906 /entity/dag/operation_pack_test.go
parentf1d4a19af81fcc05ae9d90e018ff141f6521335a (diff)
downloadgit-bug-214abe4dea1984086e45d1399538fb12aa010642.tar.gz
WIP operation with files
Diffstat (limited to 'entity/dag/operation_pack_test.go')
-rw-r--r--entity/dag/operation_pack_test.go20
1 files changed, 18 insertions, 2 deletions
diff --git a/entity/dag/operation_pack_test.go b/entity/dag/operation_pack_test.go
index a12382af..0fe98dc7 100644
--- a/entity/dag/operation_pack_test.go
+++ b/entity/dag/operation_pack_test.go
@@ -1,6 +1,7 @@
package dag
import (
+ "math/rand"
"testing"
"github.com/stretchr/testify/require"
@@ -11,10 +12,16 @@ import (
func TestOperationPackReadWrite(t *testing.T) {
repo, id1, _, resolver, def := makeTestContext()
+ blobHash1, err := repo.StoreData(randomData())
+ require.NoError(t, err)
+
+ blobHash2, err := repo.StoreData(randomData())
+ require.NoError(t, err)
+
opp := &operationPack{
Author: id1,
Operations: []Operation{
- newOp1(id1, "foo"),
+ newOp1(id1, "foo", blobHash1, blobHash2),
newOp2(id1, "bar"),
},
CreateTime: 123,
@@ -36,7 +43,7 @@ func TestOperationPackReadWrite(t *testing.T) {
opp3 := &operationPack{
Author: id1,
Operations: []Operation{
- newOp1(id1, "foo"),
+ newOp1(id1, "foo", blobHash1, blobHash2),
newOp2(id1, "bar"),
},
CreateTime: 123,
@@ -86,3 +93,12 @@ func TestOperationPackSignedReadWrite(t *testing.T) {
}
require.Equal(t, opp.Id(), opp3.Id())
}
+
+func randomData() []byte {
+ var letterRunes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ b := make([]byte, 32)
+ for i := range b {
+ b[i] = letterRunes[rand.Intn(len(letterRunes))]
+ }
+ return b
+}