@cryptotaxi247 / kubo / commits / e7e700061

add init config tests

Dominic Della Valle committed Aug 15, 2019 at 10:10 UTC e7e70006111311a143b69021388539d102f81550
3 files changed +53 -2
test/sharness/lib/test-lib.sh
+2 -2
@@ -212,12 +212,12 @@ test_set_address_vars() {
212
213 test_launch_ipfs_daemon() {
214
215 - args="$@"
215 + args=("$@")
216
217 test "$TEST_ULIMIT_PRESET" != 1 && ulimit -n 2048
218
219 test_expect_success "'ipfs daemon' succeeds" '
220 - ipfs daemon $args >actual_daemon 2>daemon_err &
220 + ipfs daemon "${args[@]}" >actual_daemon 2>daemon_err &
221 IPFS_PID=$!
222 '
223
test/sharness/t0020-init.sh
+14
@@ -163,6 +163,20 @@ test_expect_success "'ipfs config Addresses.API' looks good" '
163 test $(cat actual_config) = "/ip4/127.0.0.1/tcp/0"
164 '
165
166 +test_expect_success "ipfs init from existing config succeeds" '
167 + export ORIG_PATH=$IPFS_PATH
168 + export IPFS_PATH=$(pwd)/.ipfs-clone
169 +
170 + ipfs init "$ORIG_PATH/config" &&
171 + ipfs config Addresses.API > actual_config &&
172 + test $(cat actual_config) = "/ip4/127.0.0.1/tcp/0"
173 +'
174 +
175 +test_expect_success "clean up ipfs clone dir and reset IPFS_PATH" '
176 + rm -rf "$IPFS_PATH" &&
177 + export IPFS_PATH=$ORIG_PATH
178 +'
179 +
180 test_expect_success "clean up ipfs dir" '
181 rm -rf "$IPFS_PATH"
182 '
test/sharness/t0060-daemon.sh
+37
@@ -8,6 +8,43 @@ 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"
13 +
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
18 +'
19 +
20 +export IPFS_PATH=$CLONE_PATH
21 +test_launch_ipfs_daemon --init --init-config="$ORIG_PATH/config"
22 +test_kill_ipfs_daemon
23 +
24 +test_expect_success "daemon initialization with existing config works" '
25 + ipfs config "Datastore.Spec.child.path" >actual &&
26 + test $(cat actual) = "badgerds"
27 +'
28 +
29 +test_expect_success "clean up daemon clone" '
30 + rm -rf "$CLONE_PATH"
31 +'
32 +test_launch_ipfs_daemon --init --init-config="$ORIG_PATH/config" --init-profile=randomports
33 +test_kill_ipfs_daemon
34 +
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
40 +'
41 +
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
47 +'
48
49 test_init_ipfs
50 test_launch_ipfs_daemon