Documentation ¶
Index ¶
- Variables
- func FormatJSON(b []byte) (string, error)
- func LoadFixtures(t *testing.T, dir string)
- func NowAfterDuration(dur time.Duration) func() time.Time
- type TestConfig
- func (tc *TestConfig) AddScopesForUser(userID uint, scopes []string) error
- func (tc *TestConfig) AgentWithScopes(name string, scopes ...string) (*model.User, string, error)
- func (tc *TestConfig) Error() error
- func (tc *TestConfig) FixturePath() string
- func (tc *TestConfig) IsValid() bool
- func (tc *TestConfig) Path() string
- func (tc *TestConfig) RefreshTokenForUser(name, email string) (*model.User, string, error)
- func (tc *TestConfig) UserWithScopes(name, email string, scopes ...string) (*model.User, string, error)
Constants ¶
This section is empty.
Variables ¶
var Now = func() time.Time { return time.Date(2020, 01, 01, 12, 00, 00, 01234567, time.UTC) }
Now mocks the current time
Functions ¶
func FormatJSON ¶
FormatJSON formats json string to be added to golden file
func LoadFixtures ¶
LoadFixtures is called before executing each test, it clears db and loads data from fixtures so that each test is executed on new db
Types ¶
type TestConfig ¶
TestConfig defines configurations required for running tests APIConfig contains the db object, logger and github oauth conf fixturePath is the path to fixture directory which contains test data configPath is the path to test config file err will have error if occured during initialising the test db connection
func Config ¶
func Config() *TestConfig
Config creates the test configuration once and returns the same every time the function is called
func Setup ¶
func Setup(t *testing.T) *TestConfig
Setup when called first time will connect to test db, run migration to create tables and return TestConfig configurations. After that each time it is called it just retuns TestConfig configurations
func (*TestConfig) AddScopesForUser ¶
func (tc *TestConfig) AddScopesForUser(userID uint, scopes []string) error
AddScopesForUser adds scopes for passed User ID
func (*TestConfig) AgentWithScopes ¶
AgentWithScopes returns JWT for user with required scopes
func (*TestConfig) Error ¶
func (tc *TestConfig) Error() error
Error returns error if occured during initialising connection to test db
func (*TestConfig) FixturePath ¶
func (tc *TestConfig) FixturePath() string
FixturePath return the directory path to fixtures
func (*TestConfig) IsValid ¶
func (tc *TestConfig) IsValid() bool
IsValid checks if connection to test db is valid or not
func (*TestConfig) Path ¶
func (tc *TestConfig) Path() string
Path return the file path to test config
func (*TestConfig) RefreshTokenForUser ¶
RefreshTokenForUser returns refresh JWT for user with refresh:token scope User will have same github login and github name in db
func (*TestConfig) UserWithScopes ¶
func (tc *TestConfig) UserWithScopes(name, email string, scopes ...string) (*model.User, string, error)
UserWithScopes returns JWT for user with required scopes User will have same github login and github name in db