Skip to content

Commit 21b8aba

Browse files
committed
add init config tests
1 parent 995e674 commit 21b8aba

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed

test/sharness/t0020-init.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,21 @@ test_expect_success "'ipfs config Addresses.API' looks good" '
163163
test $(cat actual_config) = "/ip4/127.0.0.1/tcp/0"
164164
'
165165

166+
test_expect_success "ipfs init from existing config succeeds" '
167+
export ORIG_PATH=$IPFS_PATH &&
168+
export CLONE_PATH=$(pwd)/.ipfs-clone
169+
export IPFS_PATH=$CLONE_DIR &&
170+
echo "IPFS_PATH: \"$IPFS_PATH\"" &&
171+
ipfs init $ORIG_PATH/config &&
172+
ipfs config Addresses.API > actual_config &&
173+
test $(cat actual_config) = "/ip4/127.0.0.1/tcp/0"
174+
'
175+
176+
test_expect_success "clean up ipfs clone dir and reset IPFS_PATH" '
177+
rm -rf "$IPFS_PATH" &&
178+
export IPFS_PATH=$ORIG_PATH
179+
'
180+
166181
test_expect_success "clean up ipfs dir" '
167182
rm -rf "$IPFS_PATH"
168183
'

test/sharness/t0060-daemon.sh

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,52 @@ test_description="Test daemon command"
88

99
. lib/test-lib.sh
1010

11+
test_expect_success "daemon init with existing config works" '
12+
export ORIG_PATH=$(pwd)/.ipfs &&
13+
export CLONE_PATH=$(pwd)/.ipfs-clone &&
14+
ipfs init --profile=badgerds &&
15+
export IPFS_PATH=$CLONE_PATH
16+
ipfs daemon --init --init-config-file=$ORIG_PATH/config &
17+
IPFS_PID=$!
18+
test_wait_for_file 20 100ms "$IPFS_PATH/api" &&
19+
test_kill_ipfs_daemon &&
20+
ipfs config "Datastore.Spec.child.path" >actual &&
21+
test $(cat actual) = "badgerds"
22+
'
23+
24+
test_expect_success "clean up daemon clone" '
25+
rm -rf $CLONE_PATH
26+
'
27+
28+
test_expect_fail "daemon init with existing config and profiles work" '
29+
ipfs daemon --init --init-config-file=$ORIG_PATH/config --profile=randomports &
30+
IPFS_PID=$!
31+
test_wait_for_file 20 100ms "$IPFS_PATH/api" &&
32+
test_kill_ipfs_daemon &&
33+
ipfs config Addresses >clone_conf &&
34+
IPFS_PATH=$ORIG_PATH &&
35+
ipfs config Addresses >orig_conf &&
36+
test_cmp clone_conf orig_conf
37+
'
38+
39+
test_expect_success "clean up second daemon clone and source daemon" '
40+
rm -rf $CLONE_PATH
41+
rm -rf $ORIG_PATH
42+
'
43+
44+
test_expect_success "daemon init with existing config works" '
45+
export ORIG_PATH=$IPFS_PATH &&
46+
export CLONE_PATH=$(pwd)/.ipfs-clone &&
47+
ipfs init --profile=badgerds &&
48+
export IPFS_PATH=$CLONE_PATH
49+
ipfs daemon --init --init-config-file=$ORIG_PATH/config &
50+
IPFS_PID=$!
51+
test_wait_for_file 20 100ms "$IPFS_PATH/api" &&
52+
echo "badgerds" >expected &&
53+
ipfs config "Datastore.Spec.child.path" >actual &&
54+
test_kill_ipfs_daemon &&
55+
test_cmp expected actual
56+
'
1157

1258
test_init_ipfs
1359
test_launch_ipfs_daemon

0 commit comments

Comments
 (0)