forked from johannesboyne/gofakes3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
routing_test.go
32 lines (27 loc) · 766 Bytes
/
routing_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
package gofakes3_test
import (
"testing"
)
func TestRoutingSlashes(t *testing.T) {
ts := newTestServer(t, withoutInitialBuckets())
defer ts.Close()
ts.backendCreateBucket("test")
ts.backendPutString("test", "obj", nil, "yep")
client := httpClient()
assertStatus := func(url string, code int) {
t.Helper()
rs, err := client.Head(ts.url(url))
ts.OK(err)
if rs.StatusCode != code {
t.Fatal("expected status", code, "found", rs.StatusCode)
}
}
assertStatus("nope", 404) // sanity check missing URL
assertStatus("test", 200)
assertStatus("test/", 200)
assertStatus("test//", 200) // don't care how many slashes
assertStatus("test/nope", 404)
assertStatus("test/obj", 200)
assertStatus("test/obj/", 200)
assertStatus("test/obj//", 200)
}