Documentation ¶
Index ¶
- Variables
- func AssertCount(t testing.TB, bean interface{}, expected interface{})
- func AssertExistsAndLoadBean(t testing.TB, bean interface{}, conditions ...interface{}) interface{}
- func AssertExistsIf(t *testing.T, expected bool, bean interface{}, conditions ...interface{})
- func AssertInt64InRange(t testing.TB, low, high, value int64)
- func AssertNotExistsBean(t testing.TB, bean interface{}, conditions ...interface{})
- func AssertSuccessfulInsert(t testing.TB, beans ...interface{})
- func BeanExists(t testing.TB, bean interface{}, conditions ...interface{}) bool
- func Cond(query interface{}, args ...interface{}) interface{}
- func CreateUser(u *User) (err error)
- func DeleteAccessTokenByID(id, userID int64) error
- func GetCount(t testing.TB, bean interface{}, conditions ...interface{}) int
- func InitFixtures(helper testfixtures.Helper, dir string) (err error)
- func IsErrAccessTokenEmpty(err error) bool
- func IsErrAccessTokenNotExist(err error) bool
- func IsErrEmailAlreadyUsed(err error) bool
- func IsErrShortenNotExist(err error) bool
- func IsErrURLExist(err error) bool
- func IsErrUserAlreadyExist(err error) bool
- func IsErrUserNotExist(err error) bool
- func IsUserExist(uid int64, email string) (bool, error)
- func LoadFixtures() error
- func MainTest(m *testing.M, pathToRoot string)
- func NewAccessToken(t *AccessToken) error
- func NewEngine() (err error)
- func PrepareTestDatabase() error
- func PrepareTestEnv(t testing.TB)
- func SetEngine() (err error)
- func UpdateAccessToken(t *AccessToken) error
- func UpdateUser(u *User) error
- func UpdateUserCols(u *User, cols ...string) error
- type AccessToken
- type Engine
- type ErrAccessTokenEmpty
- type ErrAccessTokenNotExist
- type ErrEmailAlreadyUsed
- type ErrShortenNotExist
- type ErrURLExist
- type ErrUserAlreadyExist
- type ErrUserNotExist
- type Shorten
- type User
Constants ¶
This section is empty.
Variables ¶
var ( // EnableSQLite3 for enable sqlite 3 EnableSQLite3 bool )
Functions ¶
func AssertCount ¶
AssertCount assert the count of a bean
func AssertExistsAndLoadBean ¶
AssertExistsAndLoadBean assert that a bean exists and load it from the test database
func AssertExistsIf ¶
AssertExistsIf asserts that a bean exists or does not exist, depending on what is expected.
func AssertInt64InRange ¶
AssertInt64InRange assert value is in range [low, high]
func AssertNotExistsBean ¶
AssertNotExistsBean assert that a bean does not exist in the test database
func AssertSuccessfulInsert ¶
AssertSuccessfulInsert assert that beans is successfully inserted
func BeanExists ¶
BeanExists for testing, check if a bean exists
func Cond ¶
func Cond(query interface{}, args ...interface{}) interface{}
Cond create a condition with arguments for a test
func DeleteAccessTokenByID ¶
DeleteAccessTokenByID deletes access token by given ID.
func InitFixtures ¶
InitFixtures initialize test fixtures for a test database
func IsErrAccessTokenEmpty ¶
IsErrAccessTokenEmpty checks if an error is a ErrAccessTokenEmpty.
func IsErrAccessTokenNotExist ¶
IsErrAccessTokenNotExist checks if an error is a ErrAccessTokenNotExist.
func IsErrEmailAlreadyUsed ¶
IsErrEmailAlreadyUsed checks if an error is a ErrEmailAlreadyUsed.
func IsErrShortenNotExist ¶
IsErrShortenNotExist checks if an error is a ErrUserNotExist.
func IsErrURLExist ¶
IsErrURLExist checks if an error is a ErrURLExist.
func IsErrUserAlreadyExist ¶
IsErrUserAlreadyExist checks if an error is a ErrUserAlreadyExists.
func IsErrUserNotExist ¶
IsErrUserNotExist checks if an error is a ErrUserNotExist.
func IsUserExist ¶
IsUserExist checks if given user email exist, the user email should be noncased unique. If uid is presented, then check will rule out that one, it is used when update a user email in settings page.
func MainTest ¶
MainTest a reusable TestMain(..) function for unit tests that need to use a test database. Creates the test database, and sets necessary settings.
func NewAccessToken ¶
func NewAccessToken(t *AccessToken) error
NewAccessToken creates new access token.
func PrepareTestDatabase ¶
func PrepareTestDatabase() error
PrepareTestDatabase load test fixtures into test database
func PrepareTestEnv ¶
PrepareTestEnv prepares the environment for unit tests. Can only be called by tests that use the above MainTest(..) function.
func UpdateAccessToken ¶
func UpdateAccessToken(t *AccessToken) error
UpdateAccessToken updates information of access token.
func UpdateUserCols ¶
UpdateUserCols update user according special columns
Types ¶
type AccessToken ¶
type AccessToken struct { ID int64 `xorm:"pk autoincr"` UserID int64 `xorm:"INDEX"` Name string Sha1 string `xorm:"UNIQUE VARCHAR(40)"` CreatedAt time.Time `xorm:"created" json:"created_at,omitempty"` UpdatedAt time.Time `xorm:"updated" json:"updated_at,omitempty"` HasRecentActivity bool `xorm:"-"` HasUsed bool `xorm:"-"` }
AccessToken represents a personal access token.
func GetAccessTokenBySHA ¶
func GetAccessTokenBySHA(sha string) (*AccessToken, error)
GetAccessTokenBySHA returns access token by given sha1.
func (*AccessToken) AfterLoad ¶
func (t *AccessToken) AfterLoad()
AfterLoad is invoked from XORM after setting the values of all fields of this object.
type Engine ¶
type Engine interface { Table(tableNameOrBean interface{}) *xorm.Session Count(...interface{}) (int64, error) Decr(column string, arg ...interface{}) *xorm.Session Delete(interface{}) (int64, error) Exec(...interface{}) (sql.Result, error) Find(interface{}, ...interface{}) error Get(interface{}) (bool, error) ID(interface{}) *xorm.Session In(string, ...interface{}) *xorm.Session Incr(column string, arg ...interface{}) *xorm.Session Insert(...interface{}) (int64, error) InsertOne(interface{}) (int64, error) Iterate(interface{}, xorm.IterFunc) error Join(joinOperator string, tablename interface{}, condition string, args ...interface{}) *xorm.Session SQL(interface{}, ...interface{}) *xorm.Session Where(interface{}, ...interface{}) *xorm.Session }
Engine represents a xorm engine or session.
type ErrAccessTokenEmpty ¶
type ErrAccessTokenEmpty struct { }
ErrAccessTokenEmpty represents a "AccessTokenEmpty" kind of error.
func (ErrAccessTokenEmpty) Error ¶
func (err ErrAccessTokenEmpty) Error() string
type ErrAccessTokenNotExist ¶
type ErrAccessTokenNotExist struct {
SHA string
}
ErrAccessTokenNotExist represents a "AccessTokenNotExist" kind of error.
func (ErrAccessTokenNotExist) Error ¶
func (err ErrAccessTokenNotExist) Error() string
type ErrEmailAlreadyUsed ¶
type ErrEmailAlreadyUsed struct {
Email string
}
ErrEmailAlreadyUsed represents a "EmailAlreadyUsed" kind of error.
func (ErrEmailAlreadyUsed) Error ¶
func (err ErrEmailAlreadyUsed) Error() string
type ErrShortenNotExist ¶
type ErrShortenNotExist struct {
Slug string
}
ErrShortenNotExist represents a "ShortenNotExist" kind of error.
func (ErrShortenNotExist) Error ¶
func (err ErrShortenNotExist) Error() string
type ErrURLExist ¶
ErrURLExist represents a "ErrURLExist" kind of error.
func (ErrURLExist) Error ¶
func (err ErrURLExist) Error() string
type ErrUserAlreadyExist ¶
type ErrUserAlreadyExist struct {
Name string
}
ErrUserAlreadyExist represents a "user already exists" error.
func (ErrUserAlreadyExist) Error ¶
func (err ErrUserAlreadyExist) Error() string
type ErrUserNotExist ¶
ErrUserNotExist represents a "UserNotExist" kind of error.
func (ErrUserNotExist) Error ¶
func (err ErrUserNotExist) Error() string
type Shorten ¶
type Shorten struct { Slug string `xorm:"pk VARCHAR(14)" json:"slug"` UserID int64 `xorm:"INDEX" json:"-"` URL string `xorm:"NOT NULL VARCHAR(620)" json:"url"` Date time.Time `json:"date"` Hits int64 `xorm:"NOT NULL DEFAULT 0" json:"hits"` Title string `xorm:"VARCHAR(512)" json:"title"` Description string `xorm:"TEXT" json:"description"` Type string `json:"type"` Image string `json:"image"` CreatedAt time.Time `xorm:"created" json:"created_at,omitempty"` UpdatedAt time.Time `xorm:"updated" json:"updated_at,omitempty"` // reference User *User `xorm:"-" json:"user"` }
Shorten shortener URL
func CreateShorten ¶
CreateShorten create url item
func GetShortenBySlug ¶
GetShortenBySlug returns the shorten object by given slug if exists.
func GetShortenFromURL ¶
GetShortenFromURL check url exist
func GetShortenURLs ¶
GetShortenURLs returns a list of urls of given user.
func (*Shorten) UpdateHits ¶
UpdateHits udpate hit count
func (*Shorten) UpdateMetaData ¶
UpdateMetaData form raw body
type User ¶
type User struct { ID int64 `xorm:"pk autoincr" json:"id,omitempty"` FullName string `json:"fullname,omitempty"` // Email is the primary email address (to be used for communication) Email string `xorm:"UNIQUE NOT NULL" json:"email,omitempty"` Location string Website string IsActive bool `xorm:"INDEX"` // Activate primary email Avatar string `xorm:"VARCHAR(2048) NOT NULL" json:"avatar,omitempty"` AvatarEmail string `xorm:"NOT NULL" json:"avatar_email,omitempty"` CreatedAt time.Time `xorm:"created" json:"created_at,omitempty"` UpdatedAt time.Time `xorm:"updated" json:"updated_at,omitempty"` LastLogin time.Time `json:"lastlogin,omitempty"` }
User represents the object of individual and member of organization.
func GetUserByEmail ¶
GetUserByEmail returns the user object by given e-mail if exists.
func GetUserByID ¶
GetUserByID returns the user object by given ID if exists.
func (*User) BeforeInsert ¶
func (u *User) BeforeInsert()
BeforeInsert will be invoked by XORM before inserting a record
func (*User) BeforeUpdate ¶
func (u *User) BeforeUpdate()
BeforeUpdate is invoked from XORM before updating this object.