Documentation ¶
Index ¶
- func Transaction(ctx context.Context, txb TxBeginner, f func(tx Executor) error) error
- func TransactionWithOptions(ctx context.Context, txb TxBeginner, opts *sql.TxOptions, ...) error
- type DB
- type EmailSender
- type ErrorRecorder
- type Executor
- type FollowingTeacher
- type GAMeasurement
- type Lesson
- type LessonFetcher
- type LessonFetcherMock
- type LessonStatusLog
- type MCountry
- type NopEmailSender
- type NopErrorRecorder
- type NotificationTimeSpan
- type StatNotifier
- type Teacher
- type TxBeginner
- type User
- type UserAPIToken
- type UserGoogle
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Transaction ¶
func TransactionWithOptions ¶
Types ¶
type EmailSender ¶
func NewNopEmailSender ¶
func NewNopEmailSender() EmailSender
type ErrorRecorder ¶
type Executor ¶
type Executor interface { Exec(query string, args ...interface{}) (sql.Result, error) Query(query string, args ...interface{}) (*sql.Rows, error) QueryRow(query string, args ...interface{}) *sql.Row ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error) QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row }
Executor can perform SQL queries. It's for abstraction of database/sql.DB
type FollowingTeacher ¶
type FollowingTeacher interface { CountFollowingTeachersByUserID(ctx context.Context, userID uint) (int, error) Create(ctx context.Context, followingTeacher *model2.FollowingTeacher) error DeleteByUserIDAndTeacherIDs(ctx context.Context, userID uint, teacherIDs []uint) error FindTeacherIDsByUserID(ctx context.Context, userID uint, fetchErrorCount int, lastLessonAt time.Time) ([]uint, error) FindTeachersByUserID(ctx context.Context, userID uint) ([]*model2.Teacher, error) FindByUserID(ctx context.Context, userID uint) ([]*model2.FollowingTeacher, error) FindByUserIDAndTeacherID(ctx context.Context, userID uint, teacherID uint) (*model2.FollowingTeacher, error) }
type GAMeasurement ¶
type Lesson ¶
type Lesson interface { Create(ctx context.Context, lesson *model2.Lesson, reload bool) error FindAllByTeacherIDsDatetimeBetween( ctx context.Context, teacherID uint, fromDate, toDate time.Time, ) ([]*model2.Lesson, error) FindAllByTeacherIDAndDatetimeAsMap( ctx context.Context, teacherID uint, lessonsArgs []*model2.Lesson, ) (map[string]*model2.Lesson, error) FindByID(ctx context.Context, id uint64) (*model2.Lesson, error) FindOrCreate(ctx context.Context, lesson *model2.Lesson, reload bool) (*model2.Lesson, error) GetNewAvailableLessons(ctx context.Context, oldLessons, newLessons []*model2.Lesson) []*model2.Lesson UpdateStatus(ctx context.Context, id uint64, newStatus string) (int64, error) }
type LessonFetcher ¶
type LessonFetcherMock ¶
type LessonFetcherMock struct { // CloseFunc mocks the Close method. CloseFunc func() // FetchFunc mocks the Fetch method. FetchFunc func(ctx context.Context, teacherID uint) (*model2.Teacher, []*model2.Lesson, error) // contains filtered or unexported fields }
LessonFetcherMock is a mock implementation of LessonFetcher.
func TestSomethingThatUsesLessonFetcher(t *testing.T) { // make and configure a mocked LessonFetcher mockedLessonFetcher := &LessonFetcherMock{ CloseFunc: func() { panic("mock out the Close method") }, FetchFunc: func(ctx context.Context, teacherID uint) (*model2.Teacher, []*model2.Lesson, error) { panic("mock out the Fetch method") }, } // use mockedLessonFetcher in code that requires LessonFetcher // and then make assertions. }
func (*LessonFetcherMock) CloseCalls ¶
func (mock *LessonFetcherMock) CloseCalls() []struct { }
CloseCalls gets all the calls that were made to Close. Check the length with:
len(mockedLessonFetcher.CloseCalls())
func (*LessonFetcherMock) Fetch ¶
func (mock *LessonFetcherMock) Fetch(ctx context.Context, teacherID uint) (*model2.Teacher, []*model2.Lesson, error)
Fetch calls FetchFunc.
func (*LessonFetcherMock) FetchCalls ¶
func (mock *LessonFetcherMock) FetchCalls() []struct { Ctx context.Context TeacherID uint }
FetchCalls gets all the calls that were made to Fetch. Check the length with:
len(mockedLessonFetcher.FetchCalls())
type LessonStatusLog ¶
type LessonStatusLog interface {
Create(ctx context.Context, log *model2.LessonStatusLog) error
}
type NopEmailSender ¶
type NopEmailSender struct{}
type NopErrorRecorder ¶
type NopErrorRecorder struct{}
type NotificationTimeSpan ¶
type StatNotifier ¶
type StatNotifier interface {
CreateOrUpdate(ctx context.Context, statNotifier *model2.StatNotifier) error
}
type Teacher ¶
type Teacher interface { Create(ctx context.Context, teacher *model2.Teacher) error CreateOrUpdate(ctx context.Context, teacher *model2.Teacher) error FindByID(ctx context.Context, id uint) (*model2.Teacher, error) FindByIDs(ctx context.Context, ids []uint) ([]*model2.Teacher, error) IncrementFetchErrorCount(ctx context.Context, id uint, value int) error }
type TxBeginner ¶
type User ¶
type User interface { CreateWithExec(ctx context.Context, exec Executor, user *model2.User) error FindAllByEmailVerifiedIsTrue(ctx context.Context, notificationInterval int) ([]*model2.User, error) FindByAPIToken(ctx context.Context, apiToken string) (*model2.User, error) FindByEmail(ctx context.Context, email string) (*model2.User, error) FindByEmailWithExec(ctx context.Context, exec Executor, email string) (*model2.User, error) FindByGoogleID(ctx context.Context, googleID string) (*model2.User, error) FindByGoogleIDWithExec(ctx context.Context, exec Executor, googleID string) (*model2.User, error) FindAllByEmailVerified(ctx context.Context, notificationInterval int) ([]*model2.User, error) UpdateEmail(ctx context.Context, id uint, email string) error UpdateFollowedTeacherAt(ctx context.Context, id uint, time time.Time) error UpdateOpenNotificationAt(ctx context.Context, id uint, time time.Time) error }
type UserAPIToken ¶
type UserGoogle ¶
type UserGoogle interface { CreateWithExec(ctx context.Context, exec Executor, userGoogle *model2.UserGoogle) error DeleteByPKWithExec(ctx context.Context, exec Executor, googleID string) error FindByPKWithExec(ctx context.Context, exec Executor, googleID string) (*model2.UserGoogle, error) FindByUserIDWithExec(ctx context.Context, exec Executor, userID uint) (*model2.UserGoogle, error) }
Click to show internal directories.
Click to hide internal directories.