sharness/t0021-config.sh test config setting
Juan Batiz-Benet committed
Feb 1, 2015 at 20:03 UTC
33144f4e3950b4310b8ff6f6f47e8f9e8badaecd
1 file changed
+60
test/sharness/t0021-config.sh
new
+60
@@ -0,0 +1,60 @@
1
+#!/bin/sh
2
+
3
+test_description="Test config command"
4
+
5
+. lib/test-lib.sh
6
+
7
+# we use a function so that we can run it both offline + online
8
+test_config_cmd_set() {
9
+
10
+ # flags (like -bool in "ipfs config -bool")
11
+ cfg_flags="" # unset in case.
12
+ test "$#" = 3 && { cfg_flags=$1; shift; }
13
+
14
+ cfg_key=$1
15
+ cfg_val=$2
16
+ test_expect_success "ipfs config succeeds" '
17
+ ipfs config $cfg_flags "$cfg_key" "$cfg_val"
18
+ '
19
+
20
+ test_expect_success "ipfs config output looks good" '
21
+ echo "$cfg_val" >expected &&
22
+ ipfs config "$cfg_key" >actual &&
23
+ test_cmp expected actual
24
+ '
25
+
26
+ # also test our lib function. it should work too.
27
+ cfg_key="Lib.$cfg_key"
28
+ test_expect_success "test_config_set succeeds" '
29
+ test_config_set $cfg_flags "$cfg_key" "$cfg_val"
30
+ '
31
+
32
+ test_expect_success "test_config_set value looks good" '
33
+ echo "$cfg_val" >expected &&
34
+ ipfs config "$cfg_key" >actual &&
35
+ test_cmp expected actual
36
+ '
37
+}
38
+
39
+
40
+test_config_cmd() {
41
+ test_config_cmd_set "beep" "boop"
42
+ test_config_cmd_set "beep1" "boop2"
43
+ test_config_cmd_set "beep1" "boop2"
44
+ test_config_cmd_set "-bool" "beep2" "true"
45
+ test_config_cmd_set "-bool" "beep2" "false"
46
+
47
+}
48
+
49
+test_init_ipfs
50
+
51
+# should work offline
52
+test_config_cmd
53
+
54
+# should work online
55
+test_launch_ipfs_daemon
56
+test_config_cmd
57
+test_kill_ipfs_daemon
58
+
59
+
60
+test_done