Skip to content

Commit

Permalink
test: fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
Ns2Kracy committed May 29, 2024
1 parent 197adae commit 2a6545a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions route/management_route_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit 2a6545a

Please sign in to comment.