summaryrefslogtreecommitdiff
path: root/internal/db/bundb/account_test.go
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2021-09-28 15:21:59 +0200
committerLibravatar GitHub <noreply@github.com>2021-09-28 15:21:59 +0200
commitb5a7e1ba323a2493873dedf3a3835c2e9564cb24 (patch)
treebaf6b49256ffc319dafa35289ee13de5f9fbb516 /internal/db/bundb/account_test.go
parentWeird notif issue (#248) (diff)
downloadgotosocial-b5a7e1ba323a2493873dedf3a3835c2e9564cb24.tar.xz
Account update issue (#250)
* start poking around * tests * notes and fiddling
Diffstat (limited to 'internal/db/bundb/account_test.go')
-rw-r--r--internal/db/bundb/account_test.go32
1 files changed, 32 insertions, 0 deletions
diff --git a/internal/db/bundb/account_test.go b/internal/db/bundb/account_test.go
index 02f94ad40..11e31b731 100644
--- a/internal/db/bundb/account_test.go
+++ b/internal/db/bundb/account_test.go
@@ -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))
}