test(sharness): simplify init-config logic
Steven Allen committed
Dec 5, 2019 at 18:22 UTC
f1b28dab955a24c462d3a873a6d6bc4f148498d9
1 file changed
+18
-22
test/sharness/t0060-daemon.sh
+18
-22
@@ -8,42 +8,38 @@ test_description="Test daemon command"
8
9
. lib/test-lib.sh
10
11
-test_expect_success "test environment initialized" '
12
- export ORIG_IPFS_PATH="$IPFS_PATH"
11
+test_expect_success "create badger config" '
12
+ ipfs init --profile=badgerds > /dev/null &&
13
+ cp "$IPFS_PATH/config" init-config
14
+'
15
14
- export ORIG_PATH="$(pwd)/.ipfs"
15
- export IPFS_PATH="$ORIG_PATH"
16
- export CLONE_PATH="$(pwd)/.ipfs-clone"
17
- ipfs init --profile=badgerds > /dev/null
16
+test_expect_success "cleanup repo" '
17
+ rm -rf "$IPFS_PATH"
18
'
19
20
-export IPFS_PATH=$CLONE_PATH
21
-test_launch_ipfs_daemon --init --init-config="$ORIG_PATH/config"
20
+test_launch_ipfs_daemon --init --init-config="$(pwd)/init-config"
21
test_kill_ipfs_daemon
22
23
test_expect_success "daemon initialization with existing config works" '
24
ipfs config "Datastore.Spec.child.path" >actual &&
26
- test $(cat actual) = "badgerds"
25
+ test $(cat actual) = "badgerds" &&
26
+ ipfs config Addresses > orig_addrs
27
'
28
29
-test_expect_success "clean up daemon clone" '
30
- rm -rf "$CLONE_PATH"
29
+test_expect_success "cleanup repo" '
30
+ rm -rf "$IPFS_PATH"
31
'
32
-test_launch_ipfs_daemon --init --init-config="$ORIG_PATH/config" --init-profile=randomports
32
+
33
+test_launch_ipfs_daemon --init --init-config="$(pwd)/init-config" --init-profile=randomports
34
test_kill_ipfs_daemon
35
35
-test_expect_failure "daemon initialization with existing config + profiles works" '
36
- ipfs config Addresses >clone_conf &&
37
- IPFS_PATH=$ORIG_PATH &&
38
- ipfs config Addresses >orig_conf &&
39
- test_cmp clone_conf orig_conf
36
+test_expect_success "daemon initialization with existing config + profiles works" '
37
+ ipfs config Addresses >new_addrs &&
38
+ test_expect_code 1 diff -q new_addrs orig_addrs
39
'
40
42
-test_expect_success "clean up test environment" '
43
- rm -rf "$CLONE_PATH"
44
- rm -rf "$ORIG_PATH"
45
-
46
- export IPFS_PATH=$ORIG_IPFS_PATH
41
+test_expect_success "cleanup repo" '
42
+ rm -rf "$IPFS_PATH"
43
'
44
45
test_init_ipfs