mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-10-29 11:42:24 -05:00
Account update issue (#250)
* start poking around * tests * notes and fiddling
This commit is contained in:
parent
b3fd9c39a3
commit
b5a7e1ba32
5 changed files with 172 additions and 12 deletions
|
|
@ -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))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue