Added control api validation test for addRoute
This commit is contained in:
@@ -1,12 +1,14 @@
|
||||
package control
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
|
||||
"github.com/BBVA/kapow/internal/server/model"
|
||||
"github.com/BBVA/kapow/internal/server/user"
|
||||
)
|
||||
|
||||
@@ -24,17 +26,31 @@ func Run(bindAddr string) {
|
||||
log.Fatal(http.ListenAndServe(bindAddr, r))
|
||||
}
|
||||
|
||||
// user.Routes.Remove() []model.Route
|
||||
var funcRemove func(id string) error
|
||||
|
||||
func removeRoute(http.ResponseWriter, *http.Request) {
|
||||
|
||||
if err := funcRemove(""); err != nil {
|
||||
fmt.Printf("Mostoles, we've had a problem")
|
||||
}
|
||||
}
|
||||
|
||||
// user.Routes.Snapshot() []model.Route
|
||||
var funcSnapshot func() []model.Route = user.Routes.Snapshot
|
||||
|
||||
func listRoutes(http.ResponseWriter, *http.Request) {
|
||||
|
||||
user.Routes.Snapshot()
|
||||
funcSnapshot()
|
||||
|
||||
}
|
||||
|
||||
// user.Routes.Append(r model.Route)
|
||||
var funcAdd func(model.Route) model.Route = user.Routes.Append
|
||||
|
||||
func addRoute(res http.ResponseWriter, req *http.Request) {
|
||||
|
||||
funcAdd(model.Route{})
|
||||
res.WriteHeader(http.StatusCreated)
|
||||
_, _ = io.Copy(res, req.Body)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user