Fix test cases for ipfs api check
License: MIT Signed-off-by: rht <rhtbot@gmail.com>
rht committed
Aug 27, 2015 at 15:41 UTC
be96d8d7d5027716e415ebef08a381e6ceb21a7f
1 file changed
+27
-6
test/sharness/t0062-daemon-api.sh
+27
-6
@@ -9,8 +9,23 @@ test_description="Test daemon command"
9
10
test_init_ipfs
11
12
-test_expect_success "client should work when there is no api file" '
13
- ipfs --api "$differentapi" id
12
+differentport=$((PORT_API + 1))
13
+differentapi="/ip4/127.0.0.1/tcp/$differentport"
14
+peerid=$(ipfs config Identity.PeerID)
15
+
16
+test_client() {
17
+ args="$@"
18
+ printf $peerid >expected
19
+ ipfs $args id -f="<id>" >actual
20
+ test_cmp expected actual
21
+}
22
+
23
+test_expect_success "client should work when there is no api file and no --api is specified" '
24
+ test_client
25
+'
26
+
27
+test_expect_success "client should err when there is no api file and with --api is specified" '
28
+ test_must_fail test_client --api "$differentapi"
29
'
30
31
test_launch_ipfs_daemon
@@ -19,8 +34,10 @@ test_expect_success "'ipfs daemon' creates api file" '
34
test -f ".ipfs/api"
35
'
36
22
-differentport=$((PORT_API + 1))
23
-differentapi="/ip4/127.0.0.1/tcp/$differentport"
37
+test_expect_success "api file looks good" '
38
+ printf "$ADDR_API" >expected &&
39
+ test_cmp expected .ipfs/api
40
+'
41
42
test_expect_success "client should err if client api != api file while daemon is on" '
43
echo "Error: api not running" >expected &&
@@ -42,12 +59,16 @@ ADDR_API=$differentapi
59
test_launch_ipfs_daemon --api "$ADDR_API"
60
61
test_expect_success "'ipfs daemon' api option works" '
45
- printf "$differentapi" > expected &&
62
+ printf "$differentapi" >expected &&
63
test_cmp expected .ipfs/api
64
'
65
66
test_expect_success "client should work if client api == api file, != cfg api while daemon is on" '
50
- ipfs --api "$differentapi" id
67
+ test_client --api "$differentapi"
68
+'
69
+
70
+test_expect_success "client should read the api file while daemon is on" '
71
+ test_client
72
'
73
74
test_kill_ipfs_daemon