Add test script for add and cat commands
License: MIT Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Christian Couder committed
Oct 31, 2014 at 22:19 UTC
e3da26d1162ebe5f2f2ee2454d453a93663d35a6
1 file changed
+72
test/t0040-add-and-cat.sh
new
+72
@@ -0,0 +1,72 @@
1
+#!/bin/sh
2
+#
3
+# Copyright (c) 2014 Christian Couder
4
+# MIT Licensed; see the LICENSE file in this repository.
5
+#
6
+
7
+test_description="Test add and cat commands"
8
+
9
+. ./test-lib.sh
10
+
11
+test_expect_success "ipfs init succeeds" '
12
+ export IPFS_DIR="$(pwd)/.go-ipfs" &&
13
+ ipfs init -b=2048
14
+'
15
+
16
+test_expect_success "prepare config" '
17
+ mkdir mountdir ipfs ipns &&
18
+ ipfs config Mounts.IPFS "$(pwd)/ipfs" &&
19
+ ipfs config Mounts.IPNS "$(pwd)/ipns"
20
+'
21
+
22
+test_expect_success "ipfs mount succeeds" '
23
+ ipfs mount mountdir >actual &
24
+'
25
+
26
+test_expect_success "ipfs mount output looks good" '
27
+ IPFS_PID=$! &&
28
+ sleep 5 &&
29
+ echo "mounting ipfs at $(pwd)/ipfs" >expected &&
30
+ echo "mounting ipns at $(pwd)/ipns" >>expected &&
31
+ test_cmp expected actual
32
+'
33
+
34
+test_expect_success "ipfs add succeeds" '
35
+ echo "Hello Worlds!" >mountdir/hello.txt &&
36
+ ipfs add mountdir/hello.txt >actual
37
+'
38
+
39
+test_expect_success "ipfs add output looks good" '
40
+ HASH="QmVr26fY1tKyspEJBniVhqxQeEjhF78XerGiqWAwraVLQH" &&
41
+ echo "added $HASH $(pwd)/mountdir/hello.txt" >expected &&
42
+ test_cmp expected actual
43
+'
44
+
45
+test_expect_success "ipfs cat succeeds" '
46
+ ipfs cat $HASH >actual
47
+'
48
+
49
+test_expect_success "ipfs cat output looks good" '
50
+ echo "Hello Worlds!" >expected &&
51
+ test_cmp expected actual
52
+'
53
+
54
+test_expect_success "cat ipfs/stuff succeeds" '
55
+ cat ipfs/$HASH >actual
56
+'
57
+
58
+test_expect_success "cat ipfs/stuff looks good" '
59
+ test_cmp expected actual
60
+'
61
+
62
+test_expect_success "ipfs mount is still running" '
63
+ kill -0 $IPFS_PID
64
+'
65
+
66
+test_expect_success "ipfs mount can be killed" '
67
+ kill $IPFS_PID &&
68
+ sleep 1 &&
69
+ ! kill -0 $IPFS_PID 2>/dev/null
70
+'
71
+
72
+test_done