Skip to content

Commit

Permalink
Add category internal testing
Browse files Browse the repository at this point in the history
  • Loading branch information
maestre3d committed Jul 20, 2020
1 parent af0e43f commit ef23af1
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions category-service/cmd/domain-test/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/alexandria-oss/core/config"
"github.com/alexandria-oss/core/logger"
"github.com/alexandria-oss/core/persistence"
"github.com/maestre3d/alexandria/category-service/internal/domain"
"github.com/maestre3d/alexandria/category-service/internal/infrastructure"
"github.com/maestre3d/alexandria/category-service/internal/interactor"
)
Expand All @@ -29,21 +30,36 @@ func main() {
eventBus := infrastructure.NewCategoryEventKafka(cfg)
categoryI := interactor.NewCategoryUseCase(log, repo, eventBus)

/*
createdCat, err := categoryI.Create(ctx, "terror")
category := new(domain.Category)
catChan := make(chan *domain.Category)
go func() {
ctx1, _ := context.WithCancel(ctx)
category, err := categoryI.Create(ctx1, "sci-fi")
if err != nil {
panic(err)
}
catChan <- category
}()
select {
case category = <-catChan:
_ = log.Log("msg", fmt.Sprintf("%+v", category))
break
}

ctx2, _ := context.WithCancel(ctx)
err = categoryI.HardDelete(ctx2, category.ExternalID)
if err != nil {
_ = log.Log("err", err)
panic(err)
}

*/

createdCat, token, err := categoryI.List(ctx, "", "1", core.FilterParams{"query": "terror"})
ctx3, _ := context.WithCancel(ctx)
categories, token, err := categoryI.List(ctx3, "", "10", core.FilterParams{"query": "terror"})
if err != nil {
panic(err)
}

for _, cat := range createdCat {
for _, cat := range categories {
_ = log.Log("output", fmt.Sprintf("%+v", cat))
}

Expand Down

0 comments on commit ef23af1

Please sign in to comment.