2021-05-08 15:25:55 +03:00
|
|
|
package user_test
|
|
|
|
|
|
|
|
import (
|
2021-09-11 22:12:47 +03:00
|
|
|
"git.iim.gay/grufwub/go-store/kv"
|
2021-05-08 15:25:55 +03:00
|
|
|
"github.com/sirupsen/logrus"
|
|
|
|
"github.com/stretchr/testify/suite"
|
|
|
|
"github.com/superseriousbusiness/gotosocial/internal/api/s2s/user"
|
2021-08-10 14:32:39 +03:00
|
|
|
"github.com/superseriousbusiness/gotosocial/internal/api/security"
|
2021-05-08 15:25:55 +03:00
|
|
|
"github.com/superseriousbusiness/gotosocial/internal/config"
|
|
|
|
"github.com/superseriousbusiness/gotosocial/internal/db"
|
|
|
|
"github.com/superseriousbusiness/gotosocial/internal/federation"
|
|
|
|
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
|
2021-05-30 14:12:00 +03:00
|
|
|
"github.com/superseriousbusiness/gotosocial/internal/processing"
|
2021-05-08 15:25:55 +03:00
|
|
|
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
|
2021-09-20 17:46:45 +03:00
|
|
|
"github.com/superseriousbusiness/gotosocial/testrig"
|
2021-05-08 15:25:55 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
type UserStandardTestSuite struct {
|
|
|
|
// standard suite interfaces
|
|
|
|
suite.Suite
|
2021-08-10 14:32:39 +03:00
|
|
|
config *config.Config
|
|
|
|
db db.DB
|
|
|
|
log *logrus.Logger
|
|
|
|
tc typeutils.TypeConverter
|
|
|
|
federator federation.Federator
|
|
|
|
processor processing.Processor
|
2021-09-11 22:12:47 +03:00
|
|
|
storage *kv.KVStore
|
2021-08-10 14:32:39 +03:00
|
|
|
securityModule *security.Module
|
2021-05-08 15:25:55 +03:00
|
|
|
|
|
|
|
// standard suite models
|
2021-09-01 12:45:01 +03:00
|
|
|
testTokens map[string]*gtsmodel.Token
|
|
|
|
testClients map[string]*gtsmodel.Client
|
2021-05-08 15:25:55 +03:00
|
|
|
testApplications map[string]*gtsmodel.Application
|
|
|
|
testUsers map[string]*gtsmodel.User
|
|
|
|
testAccounts map[string]*gtsmodel.Account
|
|
|
|
testAttachments map[string]*gtsmodel.MediaAttachment
|
|
|
|
testStatuses map[string]*gtsmodel.Status
|
|
|
|
|
|
|
|
// module being tested
|
|
|
|
userModule *user.Module
|
|
|
|
}
|
2021-09-20 17:46:45 +03:00
|
|
|
|
|
|
|
func (suite *UserStandardTestSuite) SetupSuite() {
|
|
|
|
suite.testTokens = testrig.NewTestTokens()
|
|
|
|
suite.testClients = testrig.NewTestClients()
|
|
|
|
suite.testApplications = testrig.NewTestApplications()
|
|
|
|
suite.testUsers = testrig.NewTestUsers()
|
|
|
|
suite.testAccounts = testrig.NewTestAccounts()
|
|
|
|
suite.testAttachments = testrig.NewTestAttachments()
|
|
|
|
suite.testStatuses = testrig.NewTestStatuses()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (suite *UserStandardTestSuite) SetupTest() {
|
|
|
|
suite.config = testrig.NewTestConfig()
|
|
|
|
suite.db = testrig.NewTestDB()
|
|
|
|
suite.tc = testrig.NewTestTypeConverter(suite.db)
|
|
|
|
suite.storage = testrig.NewTestStorage()
|
|
|
|
suite.log = testrig.NewTestLog()
|
|
|
|
suite.federator = testrig.NewTestFederator(suite.db, testrig.NewTestTransportController(testrig.NewMockHTTPClient(nil), suite.db), suite.storage)
|
|
|
|
suite.processor = testrig.NewTestProcessor(suite.db, suite.storage, suite.federator)
|
|
|
|
suite.userModule = user.New(suite.config, suite.processor, suite.log).(*user.Module)
|
|
|
|
suite.securityModule = security.New(suite.config, suite.db, suite.log).(*security.Module)
|
|
|
|
testrig.StandardDBSetup(suite.db, suite.testAccounts)
|
|
|
|
testrig.StandardStorageSetup(suite.storage, "../../../../testrig/media")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (suite *UserStandardTestSuite) TearDownTest() {
|
|
|
|
testrig.StandardDBTeardown(suite.db)
|
|
|
|
testrig.StandardStorageTeardown(suite.storage)
|
|
|
|
}
|