some list implemented

This commit is contained in:
César Gallego Rodríguez
2019-10-09 16:19:52 +02:00
parent 2e2fcc4edd
commit b7a7f6a006
2 changed files with 5 additions and 5 deletions
+5 -2
View File
@@ -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
-3
View File
@@ -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)