From 2a6545af4a706f7a18d9ccaaa18b17affe9e427b Mon Sep 17 00:00:00 2001 From: Ns2Kracy Date: Wed, 29 May 2024 03:28:36 +0000 Subject: [PATCH] test: fix test --- route/management_route_test.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/route/management_route_test.go b/route/management_route_test.go index 06e3291..5644bdf 100644 --- a/route/management_route_test.go +++ b/route/management_route_test.go @@ -10,6 +10,7 @@ import ( "testing" "github.com/IceWhaleTech/CasaOS-Common/utils/logger" + "github.com/labstack/echo/v4" "github.com/IceWhaleTech/CasaOS-Common/model" "github.com/IceWhaleTech/CasaOS-Gateway/service" @@ -69,6 +70,7 @@ func TestCreateRoute(t *testing.T) { req, _ := http.NewRequest(http.MethodPost, "/v1/gateway/routes", bytes.NewReader(body)) req.RemoteAddr = "127.0.0.1:0" + req.Header.Set(echo.HeaderContentType, echo.MIMEApplicationJSON) w := httptest.NewRecorder() _router.ServeHTTP(w, req) @@ -112,6 +114,7 @@ func TestChangePort(t *testing.T) { req, _ := http.NewRequest(http.MethodPut, "/v1/gateway/port", bytes.NewReader(body)) req.RemoteAddr = "127.0.0.1:0" + req.Header.Set(echo.HeaderContentType, echo.MIMEApplicationJSON) w := httptest.NewRecorder() _router.ServeHTTP(w, req) @@ -150,6 +153,7 @@ func TestChangePortNegative(t *testing.T) { req, _ := http.NewRequest(http.MethodPut, "/v1/gateway/port", bytes.NewReader(body)) req.RemoteAddr = "127.0.0.1:0" + req.Header.Set(echo.HeaderContentType, echo.MIMEApplicationJSON) w := httptest.NewRecorder() _router.ServeHTTP(w, req) @@ -159,6 +163,7 @@ func TestChangePortNegative(t *testing.T) { // get req, _ = http.NewRequest(http.MethodGet, "/v1/gateway/port", nil) + req.Header.Set(echo.HeaderContentType, echo.MIMEApplicationJSON) w = httptest.NewRecorder() _router.ServeHTTP(w, req) @@ -185,6 +190,7 @@ func TestChangePortNegative(t *testing.T) { req, _ = http.NewRequest(http.MethodPut, "/v1/gateway/port", bytes.NewReader(body)) req.RemoteAddr = "127.0.0.1:0" + req.Header.Set(echo.HeaderContentType, echo.MIMEApplicationJSON) w = httptest.NewRecorder() _router.ServeHTTP(w, req)