-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathjoin_path_test.go
More file actions
48 lines (44 loc) · 1.01 KB
/
join_path_test.go
File metadata and controls
48 lines (44 loc) · 1.01 KB
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
package arc
import "testing"
func Test_JoinPath(t *testing.T) {
tests := []struct {
name, url, path, result string
}{
{
name: "slash on url",
url: "https://miner.test/arc/",
path: "v1/txs",
result: "https://miner.test/arc/v1/txs",
},
{
name: "slashes on path",
url: "https://miner.test/arc",
path: "/v1/txs",
result: "https://miner.test/arc/v1/txs",
},
{
name: "slashes on both sides",
url: "https://miner.test/arc/",
path: "/v1/txs",
result: "https://miner.test/arc/v1/txs",
},
{
name: "no middle slashes",
url: "https://miner.test/arc",
path: "v1/txs",
result: "https://miner.test/arc/v1/txs",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
result, err := JoinPath(tt.url, tt.path)
if err != nil {
t.Fatalf("Failed to join path : %s", err)
}
t.Logf("Result : %s", result)
if result != tt.result {
t.Errorf("Wrong result url : \n got : %s\n want : %s", result, tt.result)
}
})
}
}