sharness test for pinning changes
Jeromy committed
Jan 19, 2015 at 07:18 UTC
5b20e86ed47157d599f5e1d0c056c9c2eccb50bd
1 file changed
+63
test/sharness/t0080-repo.sh
new
+63
@@ -0,0 +1,63 @@
1
+#!/bin/sh
2
+#
3
+# Copyright (c) 2014 Jeromy Johnson
4
+# MIT Licensed; see the LICENSE file in this repository.
5
+#
6
+
7
+test_description="Test ipfs repo operations"
8
+
9
+. lib/test-lib.sh
10
+
11
+test_init_ipfs
12
+test_launch_ipfs_daemon
13
+
14
+test_expect_success "'ipfs add afile' succeeds" '
15
+ echo "some text" > afile
16
+ HASH=`ipfs add -q afile`
17
+ echo -n $HASH > hashfile
18
+'
19
+
20
+test_expect_success "added file was pinned" '
21
+ ipfs pin ls -type=recursive | grep `cat hashfile`
22
+'
23
+
24
+# TODO: run gc, then ipfs cat file, should still be there
25
+
26
+test_expect_success "'ipfs pin rm' succeeds" '
27
+ echo Unpinned `cat hashfile` > expected
28
+ ipfs pin rm `cat hashfile` > actual
29
+ test_cmp expected actual
30
+'
31
+
32
+test_expect_success "file no longer pinned" '
33
+ echo -n "" > expected
34
+ ipfs pin ls -type=recursive > actual
35
+ test_cmp expected actual
36
+'
37
+
38
+test_expect_success "recursively pin afile" '
39
+ ipfs pin add -r `cat hashfile`
40
+'
41
+
42
+test_expect_success "pinning directly should fail now" '
43
+ echo "Error: pin: Key already pinned recursively." > expected
44
+ ipfs pin add `cat hashfile` 2> actual
45
+ test_cmp expected actual
46
+'
47
+
48
+test_expect_success "remove recursive pin, add direct" '
49
+ echo Unpinned `cat hashfile` > expected
50
+ ipfs pin rm `cat hashfile` > actual
51
+ test_cmp expected actual
52
+ ipfs pin add `cat hashfile`
53
+'
54
+
55
+test_expect_success "remove direct pin" '
56
+ ipfs pin rm `cat hashfile` > actual
57
+ test_cmp expected actual
58
+'
59
+
60
+
61
+test_kill_ipfs_daemon
62
+
63
+test_done