Skip to content

Commit

Permalink
comment on tests that need attention
Browse files Browse the repository at this point in the history
  • Loading branch information
fairclothjm committed May 10, 2024
1 parent 761a7e6 commit 43e50c0
Showing 1 changed file with 26 additions and 11 deletions.
37 changes: 26 additions & 11 deletions path_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,17 @@ func TestPathRegex(t *testing.T) {
input: "prefix/foo-.bar",
want: map[string]string{"value": "foo-.bar"},
},
// TODO(JM): this should work
// "multi-part-special-chars": {
"multi-part-special-chars": {
pattern: "prefix" + genericNameWithForwardSlashRegex("value"),
input: "prefix/foo-.bar/baz-.qux",
want: map[string]string{"value": "foo-.bar/baz-.qux"},
},
// TODO(JM): this should error
// "multi-part-special-chars-error": {
// pattern: "prefix" + genericNameWithForwardSlashRegex("value"),
// input: "prefix/foo-.bar/baz-.",
// want: map[string]string{"value": "foo-.bar/baz-."},
// want: nil,
// wantErr: true,
// },
// TODO(JM): this should error
// "multi-part-error-special-chars": {
Expand All @@ -83,17 +89,26 @@ func TestPathRegex(t *testing.T) {
// want: nil,
// wantErr: true,
// },
// TODO(JM): this should error
// "multi-part-error-special-chars": {
// pattern: "prefix" + genericNameWithForwardSlashRegex("value"),
// input: "prefix/foo-.@bar/baz",
// want: nil,
// wantErr: true,
// },
}

for name, tc := range tests {
re, _ := regexp.Compile(tc.pattern)
got, err := getCaptures(re, tc.input)
if tc.wantErr {
require.Error(t, err, "failed test: "+name)
} else {
require.NoError(t, err, "failed test: "+name)
require.Equal(t, tc.want, got, "failed test: "+name)
}
t.Run(name, func(t *testing.T) {
re, _ := regexp.Compile(tc.pattern)
got, err := getCaptures(re, tc.input)
if tc.wantErr {
require.Error(t, err)
} else {
require.NoError(t, err)
require.Equal(t, tc.want, got)
}
})
}
}

Expand Down

0 comments on commit 43e50c0

Please sign in to comment.