local_test.go raw
1 package io
2
3 import (
4 "strings"
5 "testing"
6 )
7
8 func TestIsBlossomPath(t *testing.T) {
9 hash := strings.Repeat("ab", 32)
10 yes := []string{
11 "/upload",
12 "/blossom/upload",
13 "/list/" + hash,
14 "/blossom/list/" + hash,
15 "/" + hash,
16 "/blossom/" + hash,
17 "/" + hash + ".jpg",
18 "/blossom/" + hash + ".jpg",
19 }
20 for _, p := range yes {
21 if !isBlossomPath(p) {
22 t.Errorf("%q: not a Blossom path", p)
23 }
24 }
25 no := []string{
26 "/",
27 "/blossom",
28 "/blossom/notahash",
29 "/" + strings.Repeat("ab", 31),
30 "/" + hash + "x",
31 }
32 for _, p := range no {
33 if isBlossomPath(p) {
34 t.Errorf("%q: unexpectedly a Blossom path", p)
35 }
36 }
37 }
38