Skip to content

Commit

Permalink
Adding test for autoredirect create and confirmation
Browse files Browse the repository at this point in the history
  • Loading branch information
milosgagovic committed Oct 24, 2023
1 parent 9d87d23 commit 2758589
Show file tree
Hide file tree
Showing 10 changed files with 139,606 additions and 12 deletions.
7 changes: 2 additions & 5 deletions domain/redirectdefinition/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type (
API struct {
qry Queries
cmd Commands
repo redirectrepository.RedirectsDefinitionRepository
repo redirectrepository.BaseRedirectsDefinitionRepository
l *zap.Logger
//meter *cmrccommonmetric.Meter
}
Expand All @@ -25,7 +25,7 @@ type (

func NewAPI(
l *zap.Logger,
repo redirectrepository.RedirectsDefinitionRepository,
repo redirectrepository.BaseRedirectsDefinitionRepository,
opts ...Option,
) (*API, error) {

Expand All @@ -37,9 +37,6 @@ func NewAPI(
if inst.l == nil {
return nil, errors.New("missing logger")
}
if inst.repo == nil {
return nil, errors.New("missing cart repository")
}
inst.cmd = Commands{
CreateRedirects: redirectcommand.CreateRedirectsHandlerComposed(
redirectcommand.CreateRedirectsHandler(inst.repo),
Expand Down
2 changes: 1 addition & 1 deletion domain/redirectdefinition/command/createredirect.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type (
)

// CreateRedirectHandler ...
func CreateRedirectHandler(repo redirectrepository.RedirectsDefinitionRepository) CreateRedirectHandlerFn {
func CreateRedirectHandler(repo redirectrepository.BaseRedirectsDefinitionRepository) CreateRedirectHandlerFn {
return func(ctx context.Context, l *zap.Logger, cmd CreateRedirect) error {
return repo.Insert(ctx, cmd.RedirectDefinition)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type (
)

// CreateRedirectsHandler ...
func CreateRedirectsHandler(repo redirectrepository.RedirectsDefinitionRepository) CreateRedirectsHandlerFn {
func CreateRedirectsHandler(repo redirectrepository.BaseRedirectsDefinitionRepository) CreateRedirectsHandlerFn {
return func(ctx context.Context, l *zap.Logger, cmd CreateRedirects) error {
l.Info("calling create automatic redirects")
newDefinitions, err := redirectdefinitionutils.AutoCreateRedirectDefinitions(l, cmd.OldState[dimension], cmd.NewState[dimension])
Expand Down
2 changes: 1 addition & 1 deletion domain/redirectdefinition/command/deleteredirect.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type (
)

// DeleteRedirectHandler ...
func DeleteRedirectHandler(repo redirectrepository.RedirectsDefinitionRepository) DeleteRedirectHandlerFn {
func DeleteRedirectHandler(repo redirectrepository.BaseRedirectsDefinitionRepository) DeleteRedirectHandlerFn {
return func(ctx context.Context, l *zap.Logger, cmd DeleteRedirect) error {
return repo.Delete(ctx, string(cmd.Source))
}
Expand Down
2 changes: 1 addition & 1 deletion domain/redirectdefinition/command/updateredirect.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type (
)

// UpdateRedirectHandler ...
func UpdateRedirectHandler(repo redirectrepository.RedirectsDefinitionRepository) UpdateRedirectHandlerFn {
func UpdateRedirectHandler(repo redirectrepository.BaseRedirectsDefinitionRepository) UpdateRedirectHandlerFn {
return func(ctx context.Context, l *zap.Logger, cmd UpdateRedirect) error {
return repo.Update(ctx, cmd.RedirectDefinition)
}
Expand Down
2 changes: 1 addition & 1 deletion domain/redirectdefinition/query/getredirects.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type (
)

// GetRedirectsHandler ...
func GetRedirectsHandler(repo redirectrepository.RedirectsDefinitionRepository) GetRedirectsHandlerFn {
func GetRedirectsHandler(repo redirectrepository.BaseRedirectsDefinitionRepository) GetRedirectsHandlerFn {
return func(ctx context.Context, l *zap.Logger) (*redirectstore.RedirectDefinitions, error) {
return repo.FindAll(ctx)
}
Expand Down
2 changes: 1 addition & 1 deletion domain/redirectdefinition/query/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type (
)

// SearchHandler ...
func SearchHandler(repo redirectrepository.RedirectsDefinitionRepository) SearchHandlerFn {
func SearchHandler(repo redirectrepository.BaseRedirectsDefinitionRepository) SearchHandlerFn {
return func(ctx context.Context, l *zap.Logger, qry Search) (*redirectstore.RedirectDefinitions, error) {
return repo.FindMany(ctx, qry.ID, string(qry.Source))
}
Expand Down
Loading

0 comments on commit 2758589

Please sign in to comment.