translation

package
v0.0.0-...-187a358 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 27, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("can not find translation in store")
View Source
var ErrSourceAlreadyExists = errors.New("translation with such source already exists")

Functions

This section is empty.

Types

type MockRepository

type MockRepository struct {
	mock.Mock
}

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 UnmarshalFromDB(
	id string,
	source string,
	transcription string,
	target string,
	authorID string,
	example string,
	tagIDs []string,
	createdAt time.Time,
	updatedAt time.Time,
	langID string,
) *Translation

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{}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL