Documentation ¶
Index ¶
- type Interface
- type InterfaceMock
- func (mock *InterfaceMock) AddTeacher(teacher store.TeacherDetails) (string, error)
- func (mock *InterfaceMock) AddTeacherCalls() []struct{ ... }
- func (mock *InterfaceMock) DeleteTeacher(teacherID string) error
- func (mock *InterfaceMock) DeleteTeacherCalls() []struct{ ... }
- func (mock *InterfaceMock) GetTeacherDetails(teacherID string) (store.TeacherDetails, error)
- func (mock *InterfaceMock) GetTeacherDetailsCalls() []struct{ ... }
- func (mock *InterfaceMock) GetTeacherFull(teacherID string) (store.Teacher, error)
- func (mock *InterfaceMock) GetTeacherFullCalls() []struct{ ... }
- func (mock *InterfaceMock) ListTeachers() ([]store.TeacherDetails, error)
- func (mock *InterfaceMock) ListTeachersCalls() []struct{}
- func (mock *InterfaceMock) SetPreferences(teacherID string, pref store.TeacherPreferences) error
- func (mock *InterfaceMock) SetPreferencesCalls() []struct{ ... }
- type Postgres
- func (p *Postgres) AddTeacher(teacher store.TeacherDetails) (string, error)
- func (p *Postgres) DeleteTeacher(teacherID string) error
- func (p *Postgres) GetTeacherDetails(teacherID string) (res store.TeacherDetails, err error)
- func (p *Postgres) GetTeacherFull(teacherID string) (store.Teacher, error)
- func (p *Postgres) ListTeachers() ([]store.TeacherDetails, error)
- func (p *Postgres) SetPreferences(teacherID string, pref store.TeacherPreferences) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Interface ¶
type Interface interface { AddTeacher(teacher store.TeacherDetails) (id string, err error) DeleteTeacher(teacherID string) error ListTeachers() ([]store.TeacherDetails, error) GetTeacherFull(teacherID string) (store.Teacher, error) SetPreferences(teacherID string, pref store.TeacherPreferences) error GetTeacherDetails(teacherID string) (res store.TeacherDetails, err error) }
Interface defines repository methods for operating with teachers
type InterfaceMock ¶
type InterfaceMock struct { // AddTeacherFunc mocks the AddTeacher method. AddTeacherFunc func(teacher store.TeacherDetails) (string, error) // DeleteTeacherFunc mocks the DeleteTeacher method. DeleteTeacherFunc func(teacherID string) error // GetTeacherDetailsFunc mocks the GetTeacherDetails method. GetTeacherDetailsFunc func(teacherID string) (store.TeacherDetails, error) // GetTeacherFullFunc mocks the GetTeacherFull method. GetTeacherFullFunc func(teacherID string) (store.Teacher, error) // ListTeachersFunc mocks the ListTeachers method. ListTeachersFunc func() ([]store.TeacherDetails, error) // SetPreferencesFunc mocks the SetPreferences method. SetPreferencesFunc func(teacherID string, pref store.TeacherPreferences) error // contains filtered or unexported fields }
InterfaceMock is a mock implementation of Interface.
func TestSomethingThatUsesInterface(t *testing.T) { // make and configure a mocked Interface mockedInterface := &InterfaceMock{ AddTeacherFunc: func(teacher store.TeacherDetails) (string, error) { panic("mock out the AddTeacher method") }, DeleteTeacherFunc: func(teacherID string) error { panic("mock out the DeleteTeacher method") }, GetTeacherDetailsFunc: func(teacherID string) (store.TeacherDetails, error) { panic("mock out the GetTeacherDetails method") }, GetTeacherFullFunc: func(teacherID string) (store.Teacher, error) { panic("mock out the GetTeacherFull method") }, ListTeachersFunc: func() ([]store.TeacherDetails, error) { panic("mock out the ListTeachers method") }, SetPreferencesFunc: func(teacherID string, pref store.TeacherPreferences) error { panic("mock out the SetPreferences method") }, } // use mockedInterface in code that requires Interface // and then make assertions. }
func (*InterfaceMock) AddTeacher ¶
func (mock *InterfaceMock) AddTeacher(teacher store.TeacherDetails) (string, error)
AddTeacher calls AddTeacherFunc.
func (*InterfaceMock) AddTeacherCalls ¶
func (mock *InterfaceMock) AddTeacherCalls() []struct { Teacher store.TeacherDetails }
AddTeacherCalls gets all the calls that were made to AddTeacher. Check the length with:
len(mockedInterface.AddTeacherCalls())
func (*InterfaceMock) DeleteTeacher ¶
func (mock *InterfaceMock) DeleteTeacher(teacherID string) error
DeleteTeacher calls DeleteTeacherFunc.
func (*InterfaceMock) DeleteTeacherCalls ¶
func (mock *InterfaceMock) DeleteTeacherCalls() []struct { TeacherID string }
DeleteTeacherCalls gets all the calls that were made to DeleteTeacher. Check the length with:
len(mockedInterface.DeleteTeacherCalls())
func (*InterfaceMock) GetTeacherDetails ¶
func (mock *InterfaceMock) GetTeacherDetails(teacherID string) (store.TeacherDetails, error)
GetTeacherDetails calls GetTeacherDetailsFunc.
func (*InterfaceMock) GetTeacherDetailsCalls ¶
func (mock *InterfaceMock) GetTeacherDetailsCalls() []struct { TeacherID string }
GetTeacherDetailsCalls gets all the calls that were made to GetTeacherDetails. Check the length with:
len(mockedInterface.GetTeacherDetailsCalls())
func (*InterfaceMock) GetTeacherFull ¶
func (mock *InterfaceMock) GetTeacherFull(teacherID string) (store.Teacher, error)
GetTeacherFull calls GetTeacherFullFunc.
func (*InterfaceMock) GetTeacherFullCalls ¶
func (mock *InterfaceMock) GetTeacherFullCalls() []struct { TeacherID string }
GetTeacherFullCalls gets all the calls that were made to GetTeacherFull. Check the length with:
len(mockedInterface.GetTeacherFullCalls())
func (*InterfaceMock) ListTeachers ¶
func (mock *InterfaceMock) ListTeachers() ([]store.TeacherDetails, error)
ListTeachers calls ListTeachersFunc.
func (*InterfaceMock) ListTeachersCalls ¶
func (mock *InterfaceMock) ListTeachersCalls() []struct { }
ListTeachersCalls gets all the calls that were made to ListTeachers. Check the length with:
len(mockedInterface.ListTeachersCalls())
func (*InterfaceMock) SetPreferences ¶
func (mock *InterfaceMock) SetPreferences(teacherID string, pref store.TeacherPreferences) error
SetPreferences calls SetPreferencesFunc.
func (*InterfaceMock) SetPreferencesCalls ¶
func (mock *InterfaceMock) SetPreferencesCalls() []struct { TeacherID string Pref store.TeacherPreferences }
SetPreferencesCalls gets all the calls that were made to SetPreferences. Check the length with:
len(mockedInterface.SetPreferencesCalls())
type Postgres ¶
type Postgres struct {
// contains filtered or unexported fields
}
Postgres implements Interface
func NewPostgres ¶
NewPostgres returns the new instance of Postgres
func (*Postgres) AddTeacher ¶
func (p *Postgres) AddTeacher(teacher store.TeacherDetails) (string, error)
AddTeacher to database
func (*Postgres) DeleteTeacher ¶
DeleteTeacher from the database
func (*Postgres) GetTeacherDetails ¶
func (p *Postgres) GetTeacherDetails(teacherID string) (res store.TeacherDetails, err error)
GetTeacherDetails for the given teacher
func (*Postgres) GetTeacherFull ¶
GetTeacherFull gets the full information about the given teacher, including references to other teachers, such as preferences in staff
func (*Postgres) ListTeachers ¶
func (p *Postgres) ListTeachers() ([]store.TeacherDetails, error)
ListTeachers from the database
func (*Postgres) SetPreferences ¶
func (p *Postgres) SetPreferences(teacherID string, pref store.TeacherPreferences) error
SetPreferences for the given teacher