router_test.go 647 B

1234567891011121314151617181920212223242526
  1. package router_test
  2. import (
  3. "net/http"
  4. "strings"
  5. "testing"
  6. "github.com/go-chi/chi"
  7. "github.com/porter-dev/porter/api/server/router"
  8. "github.com/porter-dev/porter/api/server/shared/apitest"
  9. )
  10. func TestRouter(t *testing.T) {
  11. walkFunc := func(method string, route string, handler http.Handler, middlewares ...func(http.Handler) http.Handler) error {
  12. route = strings.Replace(route, "/*/", "/", -1)
  13. t.Errorf("%s %s %d\n", method, route, len(middlewares))
  14. return nil
  15. }
  16. config := apitest.LoadConfig(t)
  17. r := router.NewAPIRouter(config)
  18. if err := chi.Walk(r, walkFunc); err != nil {
  19. t.Fatalf("Logging err: %s\n", err.Error())
  20. }
  21. }