From c2bd392c84977cdaa50d965ef3ae980be85525b4 Mon Sep 17 00:00:00 2001 From: mcrakhman Date: Thu, 7 Jul 2022 08:53:47 +0200 Subject: [PATCH] Add document build test --- data/document.go | 1 + data/document_test.go | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 data/document_test.go diff --git a/data/document.go b/data/document.go index 4fbabcac..ca52f7f5 100644 --- a/data/document.go +++ b/data/document.go @@ -37,6 +37,7 @@ func NewDocument( thread threadmodels.Thread, stateProvider InitialStateProvider, accountData *AccountData) *Document { + decoder := threadmodels.NewEd25519Decoder() return &Document{ thread: thread, diff --git a/data/document_test.go b/data/document_test.go new file mode 100644 index 00000000..b3abc82b --- /dev/null +++ b/data/document_test.go @@ -0,0 +1,28 @@ +package data + +import ( + "github.com/stretchr/testify/assert" + "testing" + + "github.com/anytypeio/go-anytype-infrastructure-experiments/data/threadbuilder" +) + +func TestDocument_Build(t *testing.T) { + thread, err := threadbuilder.NewThreadBuilderFromFile("threadbuilder/userjoinexample.yml") + if err != nil { + t.Fatal(err) + } + keychain := thread.GetKeychain() + accountData := &AccountData{ + Identity: keychain.GetIdentity("A"), + EncKey: keychain.EncryptionKeys["A"], + } + doc := NewDocument(thread, NewPlainTextDocumentStateProvider(), accountData) + res, err := doc.Build() + if err != nil { + t.Fatal(err) + } + + st := res.(*PlainTextDocumentState) + assert.Equal(t, st.Text, "some text|first") +}