drafting out test structs

This commit is contained in:
tsmethurst
2021-04-05 20:34:56 +02:00
parent ca69a4102b
commit 21ffcd98ec
6 changed files with 405 additions and 23 deletions

View File

@ -148,7 +148,7 @@ func (suite *AccountCreateTestSuite) SetupSuite() {
userID := args.Get(2).(string)
l.Infof("received userID %+v", userID)
}).Return(&models.Token{
Code: "we're authorized now!",
Access: "we're authorized now!",
}, nil)
suite.mockStorage = &storage.MockStorage{}

View File

@ -24,7 +24,6 @@ package model
import (
"crypto/rsa"
"net/url"
"time"
)
@ -54,7 +53,7 @@ type Account struct {
// When was the avatar last updated?
AvatarUpdatedAt time.Time `pg:"type:timestamp"`
// Where can the avatar be retrieved?
AvatarRemoteURL *url.URL `pg:"type:text"`
AvatarRemoteURL string
// File name of the header on local storage
HeaderFileName string
// Gif? png? jpeg?
@ -64,7 +63,7 @@ type Account struct {
// When was the header last updated?
HeaderUpdatedAt time.Time `pg:"type:timestamp"`
// Where can the header be retrieved?
HeaderRemoteURL *url.URL `pg:"type:text"`
HeaderRemoteURL string
// DisplayName for this account. Can be empty, then just the Username will be used for display purposes.
DisplayName string
// a key/value map of fields that this account has added to their profile
@ -74,13 +73,11 @@ type Account struct {
// Is this a memorial account, ie., has the user passed away?
Memorial bool
// This account has moved this account id in the database
MovedToAccountID int
MovedToAccountID string
// When was this account created?
CreatedAt time.Time `pg:"type:timestamp,notnull,default:now()"`
// When was this account last updated?
UpdatedAt time.Time `pg:"type:timestamp,notnull,default:now()"`
// When should this account function until
SubscriptionExpiresAt time.Time `pg:"type:timestamp"`
// Does this account identify itself as a bot?
Bot bool
// What reason was given for signing up when this account was created?
@ -130,7 +127,6 @@ type Account struct {
CRYPTO FIELDS
*/
Secret string
// Privatekey for validating activitypub requests, will obviously only be defined for local accounts
PrivateKey *rsa.PrivateKey
// Publickey for encoding activitypub requests, will be defined for both local and remote accounts
@ -146,12 +142,10 @@ type Account struct {
SilencedAt time.Time `pg:"type:timestamp"`
// When was this account suspended (eg., don't allow it to log in/post, don't accept media/posts from this account)
SuspendedAt time.Time `pg:"type:timestamp"`
// How much do we trust this account 🤔
TrustLevel int
// Should we hide this account's collections?
HideCollections bool
// id of the user that suspended this account through an admin action
SuspensionOrigin int
SuspensionOrigin string
}
// Field represents a key value field on an account, for things like pronouns, website, etc.

View File

@ -50,9 +50,9 @@ func GenerateURIs(username string, protocol string, host string) *URIs {
followersURI := fmt.Sprintf("%s/followers", userURI)
collectionURI := fmt.Sprintf("%s/collections/featured", userURI)
return &URIs{
HostURL: hostURL,
UserURL: userURL,
StatusesURL: statusesURL,
HostURL: hostURL,
UserURL: userURL,
StatusesURL: statusesURL,
UserURI: userURI,
StatusesURI: statusesURI,

View File

@ -32,10 +32,10 @@ var (
mentionRegex = regexp.MustCompile(mentionRegexString)
// hashtag regex can be played with here: https://regex101.com/r/Vhy8pg/1
hashtagRegexString = `(?: |^|\W)?#([a-zA-Z0-9]{1,30})(?:\b|\r)`
hashtagRegex = regexp.MustCompile(hashtagRegexString)
hashtagRegex = regexp.MustCompile(hashtagRegexString)
// emoji regex can be played with here: https://regex101.com/r/478XGM/1
emojiRegexString = `(?: |^|\W)?:([a-zA-Z0-9_]{2,30}):(?:\b|\r)?`
emojiRegex = regexp.MustCompile(emojiRegexString)
emojiRegex = regexp.MustCompile(emojiRegexString)
)
// DeriveMentions takes a plaintext (ie., not html-formatted) status,