diff options
Diffstat (limited to 'internal/db/bundb/account_test.go')
-rw-r--r-- | internal/db/bundb/account_test.go | 32 |
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 := >smodel.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)) } |