mirror of
https://github.com/openfaas/faas.git
synced 2025-06-18 12:06:37 +00:00
Add test coverage for FunctionPrefixTrimmingURLPathTransformer
Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
This commit is contained in:
committed by
Alex Ellis
parent
4367fc4e35
commit
e551d12b65
31
gateway/handlers/transparent_url_path_transformer_test.go
Normal file
31
gateway/handlers/transparent_url_path_transformer_test.go
Normal file
@ -0,0 +1,31 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func Test_Transform_DoesntTransformRootPath(t *testing.T) {
|
||||
|
||||
req, _ := http.NewRequest(http.MethodGet, "/", nil)
|
||||
transformer := TransparentURLPathTransformer{}
|
||||
want := req.URL.Path
|
||||
got := transformer.Transform(req)
|
||||
|
||||
if want != got {
|
||||
t.Errorf("want: %s, got: %s", want, got)
|
||||
}
|
||||
}
|
||||
|
||||
func Test_Transform_DoesntTransformAdditionalPath(t *testing.T) {
|
||||
|
||||
req, _ := http.NewRequest(http.MethodGet, "/employees/", nil)
|
||||
transformer := TransparentURLPathTransformer{}
|
||||
want := req.URL.Path
|
||||
got := transformer.Transform(req)
|
||||
|
||||
if want != got {
|
||||
t.Errorf("want: %s, got: %s", want, got)
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user