From 6494fe2e234ee531ca72a2ca9cec6f8a0e45637b Mon Sep 17 00:00:00 2001 From: PavelBrm Date: Sat, 21 Sep 2024 00:16:54 +1200 Subject: [PATCH] test: add pseudo-integration test --- services/skus/controllers_test.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/services/skus/controllers_test.go b/services/skus/controllers_test.go index 5222ee60c..421eb66de 100644 --- a/services/skus/controllers_test.go +++ b/services/skus/controllers_test.go @@ -1911,12 +1911,23 @@ func (suite *ControllersTestSuite) TestOrder_Cancel() { uri := "/v1/orders-new/" + ord.ID.String() - req := httptest.NewRequest(http.MethodPost, uri, bytes.NewBuffer([]byte{})) + req := httptest.NewRequest(http.MethodDelete, uri, nil) rw := httptest.NewRecorder() - oh := handlers.AppHandler(handler.NewOrder(suite.service).CreateNew) - srv := &http.Server{Addr: ":8080", Handler: oh} + oh := handler.NewOrder(suite.service) + + rtr := chi.NewRouter() + subr := chi.NewRouter() + subr.Method( + http.MethodDelete, + "/{orderID}", + handlers.AppHandler(oh.Cancel), + ) + + rtr.Mount("/v1/orders-new", subr) + + srv := &http.Server{Addr: ":8080", Handler: rtr} srv.Handler.ServeHTTP(rw, req) suite.Require().Equal(http.StatusOK, rw.Code)