Merge pull request #134 from max-schaefer/fix-test-errors

Fix frontend errors in tests
This commit is contained in:
Sauyon Lee
2020-05-13 01:38:30 -07:00
committed by GitHub
3 changed files with 242 additions and 6 deletions

View File

@@ -1,6 +1,6 @@
package main
//go:generate depstubber -vendor github.com/gorilla/mux "" Vars
//go:generate depstubber -vendor github.com/gorilla/mux "" Vars,NewRouter
import (
"fmt"

View File

@@ -2,15 +2,251 @@
// This is a simple stub for github.com/gorilla/mux, strictly for use in testing.
// See the LICENSE file for information about the licensing of the original library.
// Source: github.com/gorilla/mux (exports: ; functions: Vars)
// Source: github.com/gorilla/mux (exports: ; functions: Vars,NewRouter)
// Package mux is a stub of github.com/gorilla/mux, generated by depstubber.
package mux
import (
http "net/http"
url "net/url"
)
type BuildVarsFunc func(map[string]string) map[string]string
type MatcherFunc func(*http.Request, *RouteMatch) bool
func (_ MatcherFunc) Match(_ *http.Request, _ *RouteMatch) bool {
return false
}
type MiddlewareFunc func(http.Handler) http.Handler
func (_ MiddlewareFunc) Middleware(_ http.Handler) http.Handler {
return nil
}
func NewRouter() *Router {
return nil
}
type Route struct{}
func (_ *Route) BuildOnly() *Route {
return nil
}
func (_ *Route) BuildVarsFunc(_ BuildVarsFunc) *Route {
return nil
}
func (_ *Route) GetError() error {
return nil
}
func (_ *Route) GetHandler() http.Handler {
return nil
}
func (_ *Route) GetHostTemplate() (string, error) {
return "", nil
}
func (_ *Route) GetMethods() ([]string, error) {
return nil, nil
}
func (_ *Route) GetName() string {
return ""
}
func (_ *Route) GetPathRegexp() (string, error) {
return "", nil
}
func (_ *Route) GetPathTemplate() (string, error) {
return "", nil
}
func (_ *Route) GetQueriesRegexp() ([]string, error) {
return nil, nil
}
func (_ *Route) GetQueriesTemplates() ([]string, error) {
return nil, nil
}
func (_ *Route) Handler(_ http.Handler) *Route {
return nil
}
func (_ *Route) HandlerFunc(_ func(http.ResponseWriter, *http.Request)) *Route {
return nil
}
func (_ *Route) Headers(_ ...string) *Route {
return nil
}
func (_ *Route) HeadersRegexp(_ ...string) *Route {
return nil
}
func (_ *Route) Host(_ string) *Route {
return nil
}
func (_ *Route) Match(_ *http.Request, _ *RouteMatch) bool {
return false
}
func (_ *Route) MatcherFunc(_ MatcherFunc) *Route {
return nil
}
func (_ *Route) Methods(_ ...string) *Route {
return nil
}
func (_ *Route) Name(_ string) *Route {
return nil
}
func (_ *Route) Path(_ string) *Route {
return nil
}
func (_ *Route) PathPrefix(_ string) *Route {
return nil
}
func (_ *Route) Queries(_ ...string) *Route {
return nil
}
func (_ *Route) Schemes(_ ...string) *Route {
return nil
}
func (_ *Route) SkipClean() bool {
return false
}
func (_ *Route) Subrouter() *Router {
return nil
}
func (_ *Route) URL(_ ...string) (*url.URL, error) {
return nil, nil
}
func (_ *Route) URLHost(_ ...string) (*url.URL, error) {
return nil, nil
}
func (_ *Route) URLPath(_ ...string) (*url.URL, error) {
return nil, nil
}
type RouteMatch struct {
Route *Route
Handler http.Handler
Vars map[string]string
MatchErr error
}
type Router struct {
NotFoundHandler http.Handler
MethodNotAllowedHandler http.Handler
KeepContext bool
}
func (_ *Router) BuildVarsFunc(_ BuildVarsFunc) *Route {
return nil
}
func (_ *Router) Get(_ string) *Route {
return nil
}
func (_ *Router) GetRoute(_ string) *Route {
return nil
}
func (_ *Router) Handle(_ string, _ http.Handler) *Route {
return nil
}
func (_ *Router) HandleFunc(_ string, _ func(http.ResponseWriter, *http.Request)) *Route {
return nil
}
func (_ *Router) Headers(_ ...string) *Route {
return nil
}
func (_ *Router) Host(_ string) *Route {
return nil
}
func (_ *Router) Match(_ *http.Request, _ *RouteMatch) bool {
return false
}
func (_ *Router) MatcherFunc(_ MatcherFunc) *Route {
return nil
}
func (_ *Router) Methods(_ ...string) *Route {
return nil
}
func (_ *Router) Name(_ string) *Route {
return nil
}
func (_ *Router) NewRoute() *Route {
return nil
}
func (_ *Router) Path(_ string) *Route {
return nil
}
func (_ *Router) PathPrefix(_ string) *Route {
return nil
}
func (_ *Router) Queries(_ ...string) *Route {
return nil
}
func (_ *Router) Schemes(_ ...string) *Route {
return nil
}
func (_ *Router) ServeHTTP(_ http.ResponseWriter, _ *http.Request) {}
func (_ *Router) SkipClean(_ bool) *Router {
return nil
}
func (_ *Router) StrictSlash(_ bool) *Router {
return nil
}
func (_ *Router) Use(_ ...MiddlewareFunc) {}
func (_ *Router) UseEncodedPath() *Router {
return nil
}
func (_ *Router) Walk(_ WalkFunc) error {
return nil
}
func Vars(_ *http.Request) map[string]string {
return nil
}
type WalkFunc func(*Route, *Router, []*Route) error

View File

@@ -54,7 +54,7 @@ func goodRedirect3(url string, rw http.ResponseWriter, req *http.Request) {
func getTarget(redirect string) string {
u, _ := url.Parse(redirect)
if u.Path[0] != "/" {
if u.Path[0] != '/' {
return "/"
}
@@ -66,21 +66,21 @@ func goodRedirect4(url string, rw http.ResponseWriter, req *http.Request) {
}
func getTarget1(redirect string) string {
if redirect[0] != "/" {
if redirect[0] != '/' {
return "/"
}
return path.Clean(redirect)
}
func badRedirect2(url string, rw http.ResponseWriter, req *http.Request) {
func badRedirect1(url string, rw http.ResponseWriter, req *http.Request) {
http.Redirect(rw, req, getTarget1(url), 302)
}
func getTarget2(redirect string) string {
u, _ := url.Parse(redirect)
if u.Path[0] != "/" {
if u.Path[0] != '/' {
return "/"
}