Refactor mount related tests
This adds test_launch_ipfs_mount() and test_kill_ipfs_mount() to avoid duplicating tests to launch "ipfs mount" and to kill it. License: MIT Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Christian Couder committed
Nov 1, 2014 at 10:52 UTC
4e2763a40a794134f28fb3dbf625526ac6dc2039
3 files changed
+42
-62
test/t0030-mount.sh
+2
-31
@@ -8,37 +8,8 @@ test_description="Test mount command"
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
-'
11
+test_launch_ipfs_mount
12
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 mount is still running" '
35
- kill -0 $IPFS_PID
36
-'
37
-
38
-test_expect_success "ipfs mount can be killed" '
39
- kill $IPFS_PID &&
40
- sleep 1 &&
41
- ! kill -0 $IPFS_PID 2>/dev/null
42
-'
13
+test_kill_ipfs_mount
14
15
test_done
test/t0040-add-and-cat.sh
+2
-31
@@ -8,28 +8,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
-'
11
+test_launch_ipfs_mount
12
13
test_expect_success "ipfs add succeeds" '
14
echo "Hello Worlds!" >mountdir/hello.txt &&
@@ -59,14 +38,6 @@ test_expect_success "cat ipfs/stuff looks good" '
38
test_cmp expected actual
39
'
40
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
-'
41
+test_kill_ipfs_mount
42
43
test_done
test/test-lib.sh
+38
@@ -16,3 +16,41 @@
16
17
# Please put go-ipfs specific shell functions below
18
19
+test_launch_ipfs_mount() {
20
+
21
+ test_expect_success "ipfs init succeeds" '
22
+ export IPFS_DIR="$(pwd)/.go-ipfs" &&
23
+ ipfs init -b=2048
24
+ '
25
+
26
+ test_expect_success "prepare config" '
27
+ mkdir mountdir ipfs ipns &&
28
+ ipfs config Mounts.IPFS "$(pwd)/ipfs" &&
29
+ ipfs config Mounts.IPNS "$(pwd)/ipns"
30
+ '
31
+
32
+ test_expect_success "ipfs mount succeeds" '
33
+ ipfs mount mountdir >actual &
34
+ '
35
+
36
+ test_expect_success "ipfs mount output looks good" '
37
+ IPFS_PID=$! &&
38
+ sleep 5 &&
39
+ echo "mounting ipfs at $(pwd)/ipfs" >expected &&
40
+ echo "mounting ipns at $(pwd)/ipns" >>expected &&
41
+ test_cmp expected actual
42
+ '
43
+}
44
+
45
+test_kill_ipfs_mount() {
46
+
47
+ test_expect_success "ipfs mount is still running" '
48
+ kill -0 $IPFS_PID
49
+ '
50
+
51
+ test_expect_success "ipfs mount can be killed" '
52
+ kill $IPFS_PID &&
53
+ sleep 1 &&
54
+ ! kill -0 $IPFS_PID 2>/dev/null
55
+ '
56
+}