-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
daemon: use fsrepo.IsInitialized to test for initialization
Use fsrepo.IsInitialized to test for initialization instead of just testing if the directory exists. Also add test cases for '--init' option, including one the creates an empty directory. License: MIT Signed-off-by: Kevin Atkinson <[email protected]>
- Loading branch information
Showing
2 changed files
with
53 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/bin/sh | ||
# | ||
# Copyright (c) 2014 Juan Batiz-Benet | ||
# MIT Licensed; see the LICENSE file in this repository. | ||
# | ||
|
||
test_description="Test daemon --init command" | ||
|
||
. lib/test-lib.sh | ||
|
||
# We don't want the normal test_init_ipfs but we need to make sure the | ||
# IPFS_PATH is set correctly. | ||
export IPFS_PATH="$(pwd)/.ipfs" | ||
|
||
# safety check since we will be removing the directory | ||
if [ -e "$IPFS_PATH" ]; then | ||
echo "$IPFS_PATH exists" | ||
exit 1 | ||
fi | ||
|
||
test_ipfs_daemon_init() { | ||
# Doing it manually since we want to launch the daemon with an | ||
# empty or non-existent REPO; the normal | ||
# test_launch_ipfs_daemon does not work since it assumes the | ||
# repo was created a particular way with regard to the API | ||
# server. | ||
|
||
test_expect_success "'ipfs daemon --init' succeeds" ' | ||
ipfs daemon --init >actual_daemon 2>daemon_err & | ||
IPFS_PID=$! && | ||
sleep 2 && | ||
if ! kill -0 $IPFS_PID; then cat daemon_err; exit 1; fi | ||
' | ||
|
||
test_expect_success "'ipfs daemon' can be killed" ' | ||
test_kill_repeat_10_sec $IPFS_PID | ||
' | ||
} | ||
|
||
test_expect_success "remove \$IPFS_PATH dir" ' | ||
rm -rf "$IPFS_PATH" | ||
' | ||
test_ipfs_daemon_init | ||
|
||
test_expect_success "create empty \$IPFS_PATH dir" ' | ||
rm -rf "$IPFS_PATH" | ||
mkdir "$IPFS_PATH" | ||
' | ||
|
||
test_ipfs_daemon_init | ||
|
||
test_done |