-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathutils_test.go
63 lines (58 loc) · 1.11 KB
/
utils_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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package handler
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestRemoveEndChar(t *testing.T) {
type TestCaseGiven struct {
Source string
Suffix string
}
type TestCase struct {
Name string
Given TestCaseGiven
Expected string
}
var testCases = []TestCase{
{
Name: "Normal success",
Given: TestCaseGiven{
Source: "https://www.example.test/",
Suffix: "/",
},
Expected: "https://www.example.test",
},
{
Name: "Several suffixes",
Given: TestCaseGiven{
Source: "https://www.example.test//////",
Suffix: "/",
},
Expected: "https://www.example.test",
},
{
Name: "Empty source string",
Given: TestCaseGiven{
Source: "",
Suffix: "/",
},
Expected: "",
},
{
Name: "Empty resulting string",
Given: TestCaseGiven{
Source: "//////",
Suffix: "/",
},
Expected: "",
},
}
for _, testCase := range testCases {
t.Log(testCase.Name)
var result string
assert.NotPanics(t, func() {
result = removeEndSuffix(testCase.Given.Source, testCase.Given.Suffix)
})
assert.Equal(t, testCase.Expected, result)
}
}