Skip to content

Commit 839759a

Browse files
committedJul 14, 2015
add tests for path parsing
License: MIT Signed-off-by: Jeromy <jeromyj@gmail.com>
1 parent ce70743 commit 839759a

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed
 

‎path/path_test.go

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package path
2+
3+
import (
4+
"testing"
5+
)
6+
7+
func TestPathParsing(t *testing.T) {
8+
cases := map[string]bool{
9+
"/ipfs/QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n": true,
10+
"/ipfs/QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n/a": true,
11+
"/ipfs/QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n/a/b/c/d/e/f": true,
12+
"/ipns/QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n/a/b/c/d/e/f": true,
13+
"/ipns/QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n": true,
14+
"QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n/a/b/c/d/e/f": true,
15+
"QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n": true,
16+
"/QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n": false,
17+
"/QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n/a": false,
18+
"/ipfs/": false,
19+
"ipfs/": false,
20+
"ipfs/QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n": false,
21+
}
22+
23+
for p, expected := range cases {
24+
_, err := ParsePath(p)
25+
valid := (err == nil)
26+
if valid != expected {
27+
t.Fatalf("expected %s to have valid == %s", p, expected)
28+
}
29+
}
30+
}

0 commit comments

Comments
 (0)
Please sign in to comment.