Documentation ¶
Index ¶
- Variables
- type MockRepository
- func (_m *MockRepository) Create(translation *Translation) error
- func (_m *MockRepository) Delete(id string, authorID string) error
- func (_m *MockRepository) DeleteByAuthorID(authorID string) (int, error)
- func (_m *MockRepository) ExistByLang(langID string, authorID string) (bool, error)
- func (_m *MockRepository) ExistByTag(tagID string, authorID string) (bool, error)
- func (_m *MockRepository) Get(id string, authorID string) (*Translation, error)
- func (_m *MockRepository) Update(translation *Translation) error
- type Repository
- type Translation
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("can not find translation in store")
var ErrSourceAlreadyExists = errors.New("translation with such source already exists")
Functions ¶
This section is empty.
Types ¶
type MockRepository ¶
mockery --name=Repository --filename=repository_mock.go --output=./ --structname=MockRepository --inpackage MockRepository is an autogenerated mock type for the Repository type
func NewMockRepository ¶
func NewMockRepository(t mockConstructorTestingTNewMockRepository) *MockRepository
NewMockRepository creates a new instance of MockRepository. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
func (*MockRepository) Create ¶
func (_m *MockRepository) Create(translation *Translation) error
Create provides a mock function with given fields: translation
func (*MockRepository) Delete ¶
func (_m *MockRepository) Delete(id string, authorID string) error
Delete provides a mock function with given fields: id, authorID
func (*MockRepository) DeleteByAuthorID ¶
func (_m *MockRepository) DeleteByAuthorID(authorID string) (int, error)
DeleteByAuthorID provides a mock function with given fields: authorID
func (*MockRepository) ExistByLang ¶
func (_m *MockRepository) ExistByLang(langID string, authorID string) (bool, error)
ExistByLang provides a mock function with given fields: langID, authorID
func (*MockRepository) ExistByTag ¶
func (_m *MockRepository) ExistByTag(tagID string, authorID string) (bool, error)
ExistByTag provides a mock function with given fields: tagID, authorID
func (*MockRepository) Get ¶
func (_m *MockRepository) Get(id string, authorID string) (*Translation, error)
Get provides a mock function with given fields: id, authorID
func (*MockRepository) Update ¶
func (_m *MockRepository) Update(translation *Translation) error
Update provides a mock function with given fields: translation
type Repository ¶
type Repository interface { Create(translation *Translation) error // Create returns ErrSourceAlreadyExists if records with values for source-langId-authorID already exists Update(translation *Translation) error // Update saves the updated translation entity to store, returns ErrSourceAlreadyExists if records with values for source-langId-authorID already exists Get(id, authorID string) (*Translation, error) // Get provides translation by id and authorID, return ErrNotFound if record not exists ExistByTag(tagID, authorID string) (bool, error) // ExistByTag checks if at least one translation tagged with tagID exist ExistByLang(langID, authorID string) (bool, error) // ExistByLang checks if at least one translation created with the passed language Delete(id, authorID string) error DeleteByAuthorID(authorID string) (int, error) }
Repository defines domain translation repository methods
type Translation ¶
type Translation struct {
// contains filtered or unexported fields
}
func NewTranslation ¶
func NewTranslation(source, transcription, target, authorID, example string, tagIDs []string, langID string) (*Translation, error)
func UnmarshalFromDB ¶
func (*Translation) ApplyChanges ¶
func (t *Translation) ApplyChanges(source, transcription, target, example string, tagIds []string, langID string) error
func (*Translation) AuthorID ¶
func (t *Translation) AuthorID() string
func (*Translation) ID ¶
func (t *Translation) ID() string
func (*Translation) LangID ¶
func (t *Translation) LangID() string
func (*Translation) ToMap ¶
func (t *Translation) ToMap() map[string]interface{}