Add document build test

This commit is contained in:
mcrakhman 2022-07-07 08:53:47 +02:00 committed by Mikhail Iudin
parent 475904a266
commit c2bd392c84
No known key found for this signature in database
GPG Key ID: FAAAA8BAABDFF1C0
2 changed files with 29 additions and 0 deletions

View File

@ -37,6 +37,7 @@ func NewDocument(
thread threadmodels.Thread, thread threadmodels.Thread,
stateProvider InitialStateProvider, stateProvider InitialStateProvider,
accountData *AccountData) *Document { accountData *AccountData) *Document {
decoder := threadmodels.NewEd25519Decoder() decoder := threadmodels.NewEd25519Decoder()
return &Document{ return &Document{
thread: thread, thread: thread,

28
data/document_test.go Normal file
View File

@ -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")
}