Account update issue (#250)

* start poking around

* tests

* notes and fiddling
This commit is contained in:
tobi 2021-09-28 15:21:59 +02:00 committed by GitHub
commit b5a7e1ba32
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 172 additions and 12 deletions

View file

@ -20,10 +20,14 @@ package bundb_test
import (
"context"
"crypto/rand"
"crypto/rsa"
"testing"
"time"
"github.com/stretchr/testify/suite"
"github.com/superseriousbusiness/gotosocial/internal/ap"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
)
type AccountTestSuite struct {
@ -56,6 +60,34 @@ func (suite *AccountTestSuite) TestUpdateAccount() {
suite.WithinDuration(time.Now(), updated.UpdatedAt, 5*time.Second)
}
func (suite *AccountTestSuite) TestInsertAccountWithDefaults() {
key, err := rsa.GenerateKey(rand.Reader, 2048)
suite.NoError(err)
newAccount := &gtsmodel.Account{
ID: "01FGP5P4VJ9SPFB0T3E36Q60DW",
Username: "test_service",
Domain: "example.org",
URI: "https://example.org/users/test_service",
URL: "https://example.org/@test_service",
ActorType: ap.ActorService,
PublicKey: &key.PublicKey,
PublicKeyURI: "https://example.org/users/test_service#main-key",
}
err = suite.db.Put(context.Background(), newAccount)
suite.NoError(err)
suite.Equal("en", newAccount.Language)
suite.WithinDuration(time.Now(), newAccount.CreatedAt, 30*time.Second)
suite.WithinDuration(time.Now(), newAccount.UpdatedAt, 30*time.Second)
suite.False(newAccount.Memorial)
suite.False(newAccount.Bot)
suite.False(newAccount.Discoverable)
suite.False(newAccount.Sensitive)
suite.False(newAccount.HideCollections)
}
func TestAccountTestSuite(t *testing.T) {
suite.Run(t, new(AccountTestSuite))
}