Skip to content

Commit

Permalink
test: update unit tests after implementing backup storage support
Browse files Browse the repository at this point in the history
  • Loading branch information
jeamon committed Nov 9, 2023
1 parent 5daee12 commit d8de804
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions tests.handlers.book_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func TestCreateBookHandler(t *testing.T) {
return nil
},
}
bs := NewBookService(zap.NewNop(), nil, NewMockClocker(), mockRepo, mockQueue)
bs := NewBookService(zap.NewNop(), nil, NewMockClocker(), mockRepo, mockRepo, mockQueue)
api := NewAPIHandler(zap.NewNop(), nil, &Statistics{started: NewMockClocker().Now()}, NewMockClocker(), NewMockUIDHandler("abc", true), bs)

t.Run("should pass: valid payload", func(t *testing.T) {
Expand Down Expand Up @@ -118,7 +118,7 @@ func TestCreateBookHandler(t *testing.T) {
}
observedZapCore, observedLogs := observer.New(zap.ErrorLevel)
observedLogger := zap.New(observedZapCore)
bs = NewBookService(zap.NewNop(), nil, NewMockClocker(), mockRepo, mockQueue)
bs = NewBookService(zap.NewNop(), nil, NewMockClocker(), mockRepo, mockRepo, mockQueue)
api = NewAPIHandler(observedLogger, nil, &Statistics{started: NewMockClocker().Now()}, NewMockClocker(), NewMockUIDHandler("", false), bs)

payload := `{"title":"Test book title", "description":"Test book description", "author":"Jerome Amon", "price":"10$"}`
Expand Down Expand Up @@ -230,7 +230,7 @@ func TestDeleteOneBook_MissingBook(t *testing.T) {
}
helper := func(t *testing.T, repo BookStorage) *http.Response {
t.Helper()
bs := NewBookService(zap.NewNop(), nil, NewMockClocker(), repo, mockQueue)
bs := NewBookService(zap.NewNop(), nil, NewMockClocker(), repo, repo, mockQueue)
api := NewAPIHandler(zap.NewNop(), nil, &Statistics{started: time.Now()}, NewMockClocker(), NewMockUIDHandler("", true), bs)
missingBookID := "b:cb8f2136-fae4-4200-85d9-3533c7f8c70d"
req := httptest.NewRequest(http.MethodDelete, "/v1/books/"+missingBookID, nil)
Expand Down
6 changes: 3 additions & 3 deletions tests.router_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func TestSetupBookRoutes(t *testing.T) {
},
}

bs := NewBookService(zap.NewNop(), nil, NewMockClocker(), mockRepo, mockQueue)
bs := NewBookService(zap.NewNop(), nil, NewMockClocker(), mockRepo, mockRepo, mockQueue)
api := NewAPIHandler(zap.NewNop(), nil, &Statistics{started: NewMockClocker().Now()}, NewMockClocker(), NewMockUIDHandler("", true), bs)
router := httprouter.New()
m := &MiddlewareMap{public: (&Middlewares{}).Chain, ops: (&Middlewares{}).Chain}
Expand Down Expand Up @@ -159,7 +159,7 @@ func TestSetupOpsRoutes(t *testing.T) {
}

config := &Config{ProfilerEndpointsEnable: false}
bs := NewBookService(zap.NewNop(), config, NewMockClocker(), nil, nil)
bs := NewBookService(zap.NewNop(), config, NewMockClocker(), nil, nil, nil)
api := NewAPIHandler(zap.NewNop(), config, &Statistics{started: NewMockClocker().Now()}, NewMockClocker(), nil, bs)
router := httprouter.New()
m := &MiddlewareMap{public: (&Middlewares{}).Chain, ops: (&Middlewares{}).Chain}
Expand Down Expand Up @@ -237,7 +237,7 @@ func TestSetupRoutes(t *testing.T) {
}

config := &Config{OpsEndpointsEnable: false, ProfilerEndpointsEnable: false}
bs := NewBookService(zap.NewNop(), config, NewMockClocker(), nil, nil)
bs := NewBookService(zap.NewNop(), config, NewMockClocker(), nil, nil, nil)
api := NewAPIHandler(zap.NewNop(), config, &Statistics{started: NewMockClocker().Now()}, NewMockClocker(), NewMockUIDHandler("abc", true), bs)
m := &MiddlewareMap{public: (&Middlewares{}).Chain, ops: (&Middlewares{}).Chain}
for _, tc := range testCases {
Expand Down

0 comments on commit d8de804

Please sign in to comment.