-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Alex Schneider
authored and
Marcel Ludwig
committed
Oct 26, 2020
1 parent
6149d68
commit fc8437a
Showing
9 changed files
with
131 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
/*.coverage | ||
|
||
#binary | ||
/couper |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package request | ||
|
||
// PathParam represents the named path param object. | ||
type PathParam struct { | ||
Name string | ||
Position int | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package runtime | ||
|
||
import ( | ||
"fmt" | ||
"reflect" | ||
"testing" | ||
|
||
"github.com/avenga/couper/config/request" | ||
) | ||
|
||
func TestHandler_CreatePattern(t *testing.T) { | ||
type testCase struct { | ||
input string | ||
expPattern string | ||
expParams []*request.PathParam | ||
expErr string | ||
} | ||
|
||
for i, tc := range []testCase{ | ||
{"a", "", nil, ""}, | ||
{"/", "/", nil, ""}, | ||
{"/{", "", nil, ""}, | ||
{"/}", "", nil, ""}, | ||
{"/{}", "", nil, ""}, | ||
{"/abc", "/abc", nil, ""}, | ||
{"/abc/{x}", "/abc/{}", []*request.PathParam{{Name: "x", Position: 2}}, ""}, | ||
{"/abc/{x}/", "/abc/{}/", []*request.PathParam{{Name: "x", Position: 2}}, ""}, | ||
{"/abc/{x}/{y}/", "/abc/{}/{}/", []*request.PathParam{{Name: "x", Position: 2}, {Name: "y", Position: 3}}, ""}, | ||
} { | ||
gotPattern, gotParams, _ := createPattern(tc.input) | ||
|
||
if tc.expPattern != gotPattern { | ||
t.Errorf("%d: Expected pattern %q, got %q", i, tc.expPattern, gotPattern) | ||
} | ||
|
||
if !reflect.DeepEqual(tc.expParams, gotParams) { | ||
t.Errorf("%d: Expected params %q, got %q", i, fmt.Sprintf("%#v", tc.expParams), fmt.Sprintf("%#v", gotParams)) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters