-
Notifications
You must be signed in to change notification settings - Fork 4
/
prefix_processor_test.go
40 lines (33 loc) · 1.01 KB
/
prefix_processor_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package unis
import (
"testing"
)
func TestPrefixRemover(t *testing.T) {
tests := []originalAgainstResult{
{"/api/users/42", "api/users/42"},
{"//api/users/42/", "api/users/42/"},
{"api/users/", "api/users/"},
}
prefixRemover := NewPrefixRemover("/")
testOriginalAgainstResult(prefixRemover, tests, t)
}
func TestPrepender(t *testing.T) {
tests := []originalAgainstResult{
{"/api/users/42", "/api/users/42"},
{"//api/users\\42", "//api/users\\42"},
{"api\\////users/", "/api\\////users/"},
}
prepender := NewPrepender("/")
testOriginalAgainstResult(prepender, tests, t)
}
func TestExclusivePrepender(t *testing.T) {
tests := []originalAgainstResult{
{"/api/users/42", "/api/users/42"},
// the only difference from simple Prepender is that this ExclusivePrepender
// will make sure that we have only one slash as a prefix.
{"//api/users\\42", "/api/users\\42"},
{"api\\////users/", "/api\\////users/"},
}
prepender := NewExclusivePrepender("/")
testOriginalAgainstResult(prepender, tests, t)
}