Documentation ¶
Overview ¶
Package repository is a generated GoMock package.
Index ¶
- type Configs
- type Error
- type MockStorer
- func (m *MockStorer) Add(ctx context.Context, shortened models.URLShortened) error
- func (m *MockStorer) Delete(ctx context.Context, slug string) error
- func (m *MockStorer) EXPECT() *MockStorerMockRecorder
- func (m *MockStorer) Get(ctx context.Context, slug string) (models.URLShortened, error)
- func (m *MockStorer) GetURL(ctx context.Context, url string) (models.URLShortened, error)
- func (m *MockStorer) Update(ctx context.Context, newshortened models.URLShortened) error
- type MockStorerMockRecorder
- func (mr *MockStorerMockRecorder) Add(ctx, shortened interface{}) *gomock.Call
- func (mr *MockStorerMockRecorder) Delete(ctx, slug interface{}) *gomock.Call
- func (mr *MockStorerMockRecorder) Get(ctx, slug interface{}) *gomock.Call
- func (mr *MockStorerMockRecorder) GetURL(ctx, url interface{}) *gomock.Call
- func (mr *MockStorerMockRecorder) Update(ctx, newshortened interface{}) *gomock.Call
- type MongoDBURLStorer
- func (m MongoDBURLStorer) Add(ctx context.Context, shortened models.URLShortened) error
- func (m MongoDBURLStorer) Delete(ctx context.Context, slug string) error
- func (m MongoDBURLStorer) Get(ctx context.Context, slug string) (models.URLShortened, error)
- func (m MongoDBURLStorer) GetURL(ctx context.Context, url string) (models.URLShortened, error)
- func (m MongoDBURLStorer) Update(ctx context.Context, newshort models.URLShortened) error
- type Storer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Configs ¶
type Configs struct {
User, Pass, Host, Port, DB, Collection string
}
Configs MongoDB configuration
func BuildMongoConfigs ¶
func BuildMongoConfigs() Configs
BuildMongoConfigs parses MongoDB configurations from the environment.
type Error ¶
type Error string
Error represents an error returned by the repository.
const ( // ErrSlugAlreadyInUse is returned when trying to store a shortened url with a slug already in use. ErrSlugAlreadyInUse Error = `slug in use` // ErrSlugNotFound is returned when trying to retrieve a slug that could not be found in the repository. ErrSlugNotFound Error = `slug not found` // ErrURLNotFound is returned when trying to retrieve a URL that could not be found in the repository. ErrURLNotFound Error = `url not found` )
type MockStorer ¶
type MockStorer struct {
// contains filtered or unexported fields
}
MockStorer is a mock of Storer interface
func NewMockStorer ¶
func NewMockStorer(ctrl *gomock.Controller) *MockStorer
NewMockStorer creates a new mock instance
func (*MockStorer) Add ¶
func (m *MockStorer) Add(ctx context.Context, shortened models.URLShortened) error
Add mocks base method
func (*MockStorer) Delete ¶
func (m *MockStorer) Delete(ctx context.Context, slug string) error
Delete mocks base method
func (*MockStorer) EXPECT ¶
func (m *MockStorer) EXPECT() *MockStorerMockRecorder
EXPECT returns an object that allows the caller to indicate expected use
func (*MockStorer) Get ¶
func (m *MockStorer) Get(ctx context.Context, slug string) (models.URLShortened, error)
Get mocks base method
func (*MockStorer) GetURL ¶
func (m *MockStorer) GetURL(ctx context.Context, url string) (models.URLShortened, error)
GetURL mocks base method
func (*MockStorer) Update ¶
func (m *MockStorer) Update(ctx context.Context, newshortened models.URLShortened) error
Update mocks base method
type MockStorerMockRecorder ¶
type MockStorerMockRecorder struct {
// contains filtered or unexported fields
}
MockStorerMockRecorder is the mock recorder for MockStorer
func (*MockStorerMockRecorder) Add ¶
func (mr *MockStorerMockRecorder) Add(ctx, shortened interface{}) *gomock.Call
Add indicates an expected call of Add
func (*MockStorerMockRecorder) Delete ¶
func (mr *MockStorerMockRecorder) Delete(ctx, slug interface{}) *gomock.Call
Delete indicates an expected call of Delete
func (*MockStorerMockRecorder) Get ¶
func (mr *MockStorerMockRecorder) Get(ctx, slug interface{}) *gomock.Call
Get indicates an expected call of Get
func (*MockStorerMockRecorder) GetURL ¶
func (mr *MockStorerMockRecorder) GetURL(ctx, url interface{}) *gomock.Call
GetURL indicates an expected call of GetURL
func (*MockStorerMockRecorder) Update ¶
func (mr *MockStorerMockRecorder) Update(ctx, newshortened interface{}) *gomock.Call
Update indicates an expected call of Update
type MongoDBURLStorer ¶
type MongoDBURLStorer struct {
// contains filtered or unexported fields
}
MongoDBStorer implements the Storer using a MongoDB store.
func NewMongoDBURLStorer ¶
func NewMongoDBURLStorer(coll *mongo.Collection) MongoDBURLStorer
NewMongoDBURLStorer returns a new instance of a MongoDBURLStorer.
func (MongoDBURLStorer) Add ¶
func (m MongoDBURLStorer) Add(ctx context.Context, shortened models.URLShortened) error
Add adds a shortened url to the mongodb repository. Returns an error if any.
func (MongoDBURLStorer) Delete ¶
func (m MongoDBURLStorer) Delete(ctx context.Context, slug string) error
Delete deletes a shortened url from the mongodb repository. Returns an error if any.
func (MongoDBURLStorer) Get ¶
func (m MongoDBURLStorer) Get(ctx context.Context, slug string) (models.URLShortened, error)
Get gets a original url using the slug from the mongodb repository. Returns an error if any.
func (MongoDBURLStorer) GetURL ¶
func (m MongoDBURLStorer) GetURL(ctx context.Context, url string) (models.URLShortened, error)
GetURL gets a shortened url from the mongodb repository. Returns an error if any.
func (MongoDBURLStorer) Update ¶
func (m MongoDBURLStorer) Update(ctx context.Context, newshort models.URLShortened) error
Update deletes a shortened url from the mongodb repository. Returns an error if any.
type Storer ¶
type Storer interface { Add(ctx context.Context, shortened models.URLShortened) error Get(ctx context.Context, slug string) (models.URLShortened, error) GetURL(ctx context.Context, url string) (models.URLShortened, error) Update(ctx context.Context, newshortened models.URLShortened) error Delete(ctx context.Context, slug string) error }
Storer defines the behaviour of a component capable of storing shortened urls, retrieving and deleting existing ones.