From b7a7f6a006fc0eec067e3677be870517f336da33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20Gallego=20Rodr=C3=ADguez?= Date: Wed, 9 Oct 2019 16:19:52 +0200 Subject: [PATCH] some list implemented --- internal/server/control/control.go | 7 +++++-- internal/server/control/control_test.go | 3 --- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/internal/server/control/control.go b/internal/server/control/control.go index ec32bf4..c2d15b9 100644 --- a/internal/server/control/control.go +++ b/internal/server/control/control.go @@ -44,8 +44,11 @@ var funcList func() []model.Route = user.Routes.List func listRoutes(res http.ResponseWriter, req *http.Request) { - funcList() - res.WriteHeader(http.StatusNotFound) + list := funcList() + + listBytes, _ := json.Marshal(list) + res.Header().Set("Content-Type", "application/json") + res.Write(listBytes) } // user.Routes.Append(r model.Route) model.Route diff --git a/internal/server/control/control_test.go b/internal/server/control/control_test.go index 3c792e0..541011b 100644 --- a/internal/server/control/control_test.go +++ b/internal/server/control/control_test.go @@ -49,7 +49,6 @@ func TestAddRouteReturns422ErrorWhenMandatoryFieldsMissing(t *testing.T) { } func TestAddRouteReturnsCreated(t *testing.T) { - t.Skip("****** WIP ******") reqPayload := `{ "method": "GET", "url_pattern": "/hello", @@ -134,7 +133,6 @@ func TestRemoveRouteReturnsNoContent(t *testing.T) { } func TestListRoutesReturnsEmptyList(t *testing.T) { - t.Skip("****** WIP ******") req := httptest.NewRequest(http.MethodGet, "/routes/", nil) resp := httptest.NewRecorder() handler := http.HandlerFunc(listRoutes) @@ -155,7 +153,6 @@ func TestListRoutesReturnsEmptyList(t *testing.T) { } func TestListRoutesReturnsTwoElementsList(t *testing.T) { - t.Skip("****** WIP ******") req := httptest.NewRequest(http.MethodGet, "/routes", nil) resp := httptest.NewRecorder() handler := http.HandlerFunc(listRoutes)