aboutsummaryrefslogtreecommitdiffstats
path: root/community/rest-server/0001-Fix-tests.patch
blob: 62ba2aa105d6032033d4769d959af82a81060a5f (plain) (blame)
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
From 4b8ef2cbd7f27ebbc69626f5b05bd9e5e8f88ce5 Mon Sep 17 00:00:00 2001
From: Alexander Neumann <alexander@bumpern.de>
Date: Sun, 13 Sep 2020 12:08:46 +0200
Subject: [PATCH] Fix tests

---
 handlers_test.go | 27 +++++++++++++--------------
 1 file changed, 13 insertions(+), 14 deletions(-)

diff --git a/handlers_test.go b/handlers_test.go
index abbba3e..65cdf92 100644
--- a/handlers_test.go
+++ b/handlers_test.go
@@ -16,25 +16,24 @@ import (
 
 func TestJoin(t *testing.T) {
 	var tests = []struct {
-		base, name string
-		result     string
+		base   string
+		names  []string
+		result string
 	}{
-		{"/", "foo/bar", "/foo/bar"},
-		{"/srv/server", "foo/bar", "/srv/server/foo/bar"},
-		{"/srv/server", "/foo/bar", "/srv/server/foo/bar"},
-		{"/srv/server", "foo/../bar", "/srv/server/bar"},
-		{"/srv/server", "../bar", "/srv/server/bar"},
-		{"/srv/server", "..", "/srv/server"},
-		{"/srv/server", "../..", "/srv/server"},
-		{"/srv/server", "/repo/data/", "/srv/server/repo/data"},
-		{"/srv/server", "/repo/data/../..", "/srv/server"},
-		{"/srv/server", "/repo/data/../data/../../..", "/srv/server"},
-		{"/srv/server", "/repo/data/../data/../../..", "/srv/server"},
+		{"/", []string{"foo", "bar"}, "/foo/bar"},
+		{"/srv/server", []string{"foo", "bar"}, "/srv/server/foo/bar"},
+		{"/srv/server", []string{"foo", "..", "bar"}, "/srv/server/foo/bar"},
+		{"/srv/server", []string{"..", "bar"}, "/srv/server/bar"},
+		{"/srv/server", []string{".."}, "/srv/server"},
+		{"/srv/server", []string{"..", ".."}, "/srv/server"},
+		{"/srv/server", []string{"repo", "data"}, "/srv/server/repo/data"},
+		{"/srv/server", []string{"repo", "data", "..", ".."}, "/srv/server/repo/data"},
+		{"/srv/server", []string{"repo", "data", "..", "data", "..", "..", ".."}, "/srv/server/repo/data/data"},
 	}
 
 	for _, test := range tests {
 		t.Run("", func(t *testing.T) {
-			got, err := join(filepath.FromSlash(test.base), test.name)
+			got, err := join(filepath.FromSlash(test.base), test.names...)
 			if err != nil {
 				t.Fatal(err)
 			}