Documentation ¶
Overview ¶
Package uni defines interface for university organization database repository and provides some implementations of this interface
Index ¶
- type Interface
- type InterfaceMock
- func (mock *InterfaceMock) AddCourse(course store.Course) (string, error)
- func (mock *InterfaceMock) AddCourseCalls() []struct{ ... }
- func (mock *InterfaceMock) AddGroup(g store.Group) (string, error)
- func (mock *InterfaceMock) AddGroupCalls() []struct{ ... }
- func (mock *InterfaceMock) AddStudyYear(sy store.StudyYear) (string, error)
- func (mock *InterfaceMock) AddStudyYearCalls() []struct{ ... }
- func (mock *InterfaceMock) DeleteGroup(id string) error
- func (mock *InterfaceMock) DeleteGroupCalls() []struct{ ... }
- func (mock *InterfaceMock) DeleteStudyYear(studyYearID string) error
- func (mock *InterfaceMock) DeleteStudyYearCalls() []struct{ ... }
- func (mock *InterfaceMock) GetCourseDetails(id string) (store.Course, error)
- func (mock *InterfaceMock) GetCourseDetailsCalls() []struct{ ... }
- func (mock *InterfaceMock) GetGroup(id string) (store.Group, error)
- func (mock *InterfaceMock) GetGroupCalls() []struct{ ... }
- func (mock *InterfaceMock) GetStudyYear(id string) (store.StudyYear, error)
- func (mock *InterfaceMock) GetStudyYearCalls() []struct{ ... }
- func (mock *InterfaceMock) ListCourses() ([]string, error)
- func (mock *InterfaceMock) ListCoursesCalls() []struct{}
- func (mock *InterfaceMock) ListGroups() ([]store.Group, error)
- func (mock *InterfaceMock) ListGroupsCalls() []struct{}
- func (mock *InterfaceMock) ListStudyYears() ([]store.StudyYear, error)
- func (mock *InterfaceMock) ListStudyYearsCalls() []struct{}
- func (mock *InterfaceMock) ListTimeSlots() ([]store.TimeSlot, error)
- func (mock *InterfaceMock) ListTimeSlotsCalls() []struct{}
- type Postgres
- func (p *Postgres) AddCourse(course store.Course) (id string, err error)
- func (p *Postgres) AddGroup(g store.Group) (id string, err error)
- func (p *Postgres) AddStudyYear(sy store.StudyYear) (id string, err error)
- func (p *Postgres) DeleteGroup(id string) error
- func (p *Postgres) DeleteStudyYear(studyYearID string) error
- func (p *Postgres) GetCourseDetails(id string) (res store.Course, err error)
- func (p *Postgres) GetGroup(id string) (g store.Group, err error)
- func (p *Postgres) GetStudyYear(id string) (sy store.StudyYear, err error)
- func (p *Postgres) ListCourses() (ids []string, err error)
- func (p *Postgres) ListGroups() (res []store.Group, err error)
- func (p *Postgres) ListStudyYears() (res []store.StudyYear, err error)
- func (p *Postgres) ListTimeSlots() (res []store.TimeSlot, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Interface ¶
type Interface interface { AddGroup(g store.Group) (id string, err error) ListGroups() ([]store.Group, error) GetGroup(id string) (g store.Group, err error) DeleteGroup(id string) error AddStudyYear(sy store.StudyYear) (id string, err error) GetStudyYear(id string) (sy store.StudyYear, err error) DeleteStudyYear(studyYearID string) error ListStudyYears() ([]store.StudyYear, error) AddCourse(course store.Course) (id string, err error) GetCourseDetails(id string) (store.Course, error) ListTimeSlots() ([]store.TimeSlot, error) ListCourses() ([]string, error) }
Interface describes database repository methods to get/set and delete groups
type InterfaceMock ¶
type InterfaceMock struct { // AddCourseFunc mocks the AddCourse method. AddCourseFunc func(course store.Course) (string, error) // AddGroupFunc mocks the AddGroup method. AddGroupFunc func(g store.Group) (string, error) // AddStudyYearFunc mocks the AddStudyYear method. AddStudyYearFunc func(sy store.StudyYear) (string, error) // DeleteGroupFunc mocks the DeleteGroup method. DeleteGroupFunc func(id string) error // DeleteStudyYearFunc mocks the DeleteStudyYear method. DeleteStudyYearFunc func(studyYearID string) error // GetCourseDetailsFunc mocks the GetCourseDetails method. GetCourseDetailsFunc func(id string) (store.Course, error) // GetGroupFunc mocks the GetGroup method. GetGroupFunc func(id string) (store.Group, error) // GetStudyYearFunc mocks the GetStudyYear method. GetStudyYearFunc func(id string) (store.StudyYear, error) // ListCoursesFunc mocks the ListCourses method. ListCoursesFunc func() ([]string, error) // ListGroupsFunc mocks the ListGroups method. ListGroupsFunc func() ([]store.Group, error) // ListStudyYearsFunc mocks the ListStudyYears method. ListStudyYearsFunc func() ([]store.StudyYear, error) // ListTimeSlotsFunc mocks the ListTimeSlots method. ListTimeSlotsFunc func() ([]store.TimeSlot, 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{ AddCourseFunc: func(course store.Course) (string, error) { panic("mock out the AddCourse method") }, AddGroupFunc: func(g store.Group) (string, error) { panic("mock out the AddGroup method") }, AddStudyYearFunc: func(sy store.StudyYear) (string, error) { panic("mock out the AddStudyYear method") }, DeleteGroupFunc: func(id string) error { panic("mock out the DeleteGroup method") }, DeleteStudyYearFunc: func(studyYearID string) error { panic("mock out the DeleteStudyYear method") }, GetCourseDetailsFunc: func(id string) (store.Course, error) { panic("mock out the GetCourseDetails method") }, GetGroupFunc: func(id string) (store.Group, error) { panic("mock out the GetGroup method") }, GetStudyYearFunc: func(id string) (store.StudyYear, error) { panic("mock out the GetStudyYear method") }, ListCoursesFunc: func() ([]string, error) { panic("mock out the ListCourses method") }, ListGroupsFunc: func() ([]store.Group, error) { panic("mock out the ListGroups method") }, ListStudyYearsFunc: func() ([]store.StudyYear, error) { panic("mock out the ListStudyYears method") }, ListTimeSlotsFunc: func() ([]store.TimeSlot, error) { panic("mock out the ListTimeSlots method") }, } // use mockedInterface in code that requires Interface // and then make assertions. }
func (*InterfaceMock) AddCourse ¶
func (mock *InterfaceMock) AddCourse(course store.Course) (string, error)
AddCourse calls AddCourseFunc.
func (*InterfaceMock) AddCourseCalls ¶
func (mock *InterfaceMock) AddCourseCalls() []struct { Course store.Course }
AddCourseCalls gets all the calls that were made to AddCourse. Check the length with:
len(mockedInterface.AddCourseCalls())
func (*InterfaceMock) AddGroup ¶
func (mock *InterfaceMock) AddGroup(g store.Group) (string, error)
AddGroup calls AddGroupFunc.
func (*InterfaceMock) AddGroupCalls ¶
func (mock *InterfaceMock) AddGroupCalls() []struct { G store.Group }
AddGroupCalls gets all the calls that were made to AddGroup. Check the length with:
len(mockedInterface.AddGroupCalls())
func (*InterfaceMock) AddStudyYear ¶
func (mock *InterfaceMock) AddStudyYear(sy store.StudyYear) (string, error)
AddStudyYear calls AddStudyYearFunc.
func (*InterfaceMock) AddStudyYearCalls ¶
func (mock *InterfaceMock) AddStudyYearCalls() []struct { Sy store.StudyYear }
AddStudyYearCalls gets all the calls that were made to AddStudyYear. Check the length with:
len(mockedInterface.AddStudyYearCalls())
func (*InterfaceMock) DeleteGroup ¶
func (mock *InterfaceMock) DeleteGroup(id string) error
DeleteGroup calls DeleteGroupFunc.
func (*InterfaceMock) DeleteGroupCalls ¶
func (mock *InterfaceMock) DeleteGroupCalls() []struct { ID string }
DeleteGroupCalls gets all the calls that were made to DeleteGroup. Check the length with:
len(mockedInterface.DeleteGroupCalls())
func (*InterfaceMock) DeleteStudyYear ¶
func (mock *InterfaceMock) DeleteStudyYear(studyYearID string) error
DeleteStudyYear calls DeleteStudyYearFunc.
func (*InterfaceMock) DeleteStudyYearCalls ¶
func (mock *InterfaceMock) DeleteStudyYearCalls() []struct { StudyYearID string }
DeleteStudyYearCalls gets all the calls that were made to DeleteStudyYear. Check the length with:
len(mockedInterface.DeleteStudyYearCalls())
func (*InterfaceMock) GetCourseDetails ¶
func (mock *InterfaceMock) GetCourseDetails(id string) (store.Course, error)
GetCourseDetails calls GetCourseDetailsFunc.
func (*InterfaceMock) GetCourseDetailsCalls ¶
func (mock *InterfaceMock) GetCourseDetailsCalls() []struct { ID string }
GetCourseDetailsCalls gets all the calls that were made to GetCourseDetails. Check the length with:
len(mockedInterface.GetCourseDetailsCalls())
func (*InterfaceMock) GetGroup ¶
func (mock *InterfaceMock) GetGroup(id string) (store.Group, error)
GetGroup calls GetGroupFunc.
func (*InterfaceMock) GetGroupCalls ¶
func (mock *InterfaceMock) GetGroupCalls() []struct { ID string }
GetGroupCalls gets all the calls that were made to GetGroup. Check the length with:
len(mockedInterface.GetGroupCalls())
func (*InterfaceMock) GetStudyYear ¶
func (mock *InterfaceMock) GetStudyYear(id string) (store.StudyYear, error)
GetStudyYear calls GetStudyYearFunc.
func (*InterfaceMock) GetStudyYearCalls ¶
func (mock *InterfaceMock) GetStudyYearCalls() []struct { ID string }
GetStudyYearCalls gets all the calls that were made to GetStudyYear. Check the length with:
len(mockedInterface.GetStudyYearCalls())
func (*InterfaceMock) ListCourses ¶
func (mock *InterfaceMock) ListCourses() ([]string, error)
ListCourses calls ListCoursesFunc.
func (*InterfaceMock) ListCoursesCalls ¶
func (mock *InterfaceMock) ListCoursesCalls() []struct { }
ListCoursesCalls gets all the calls that were made to ListCourses. Check the length with:
len(mockedInterface.ListCoursesCalls())
func (*InterfaceMock) ListGroups ¶
func (mock *InterfaceMock) ListGroups() ([]store.Group, error)
ListGroups calls ListGroupsFunc.
func (*InterfaceMock) ListGroupsCalls ¶
func (mock *InterfaceMock) ListGroupsCalls() []struct { }
ListGroupsCalls gets all the calls that were made to ListGroups. Check the length with:
len(mockedInterface.ListGroupsCalls())
func (*InterfaceMock) ListStudyYears ¶
func (mock *InterfaceMock) ListStudyYears() ([]store.StudyYear, error)
ListStudyYears calls ListStudyYearsFunc.
func (*InterfaceMock) ListStudyYearsCalls ¶
func (mock *InterfaceMock) ListStudyYearsCalls() []struct { }
ListStudyYearsCalls gets all the calls that were made to ListStudyYears. Check the length with:
len(mockedInterface.ListStudyYearsCalls())
func (*InterfaceMock) ListTimeSlots ¶
func (mock *InterfaceMock) ListTimeSlots() ([]store.TimeSlot, error)
ListTimeSlots calls ListTimeSlotsFunc.
func (*InterfaceMock) ListTimeSlotsCalls ¶
func (mock *InterfaceMock) ListTimeSlotsCalls() []struct { }
ListTimeSlotsCalls gets all the calls that were made to ListTimeSlots. Check the length with:
len(mockedInterface.ListTimeSlotsCalls())
type Postgres ¶
type Postgres struct {
// contains filtered or unexported fields
}
Postgres implements Interface with postgres queries
func NewPostgres ¶
NewPostgres returns the new instance of Postgres
func (*Postgres) AddStudyYear ¶
AddStudyYear to database
func (*Postgres) DeleteGroup ¶
DeleteGroup from the database
func (*Postgres) DeleteStudyYear ¶
DeleteStudyYear from the database
func (*Postgres) GetCourseDetails ¶
GetCourseDetails by id
func (*Postgres) GetStudyYear ¶
GetStudyYear by its id
func (*Postgres) ListCourses ¶
ListCourses that are registered in the database
func (*Postgres) ListGroups ¶
ListGroups registered in the database
func (*Postgres) ListStudyYears ¶
ListStudyYears from the database