| 1 | #!/usr/bin/env bash |
| 2 | # |
| 3 | # Copyright (c) 2017 Jeromy Johnson |
| 4 | # MIT Licensed; see the LICENSE file in this repository. |
| 5 | # |
| 6 | |
| 7 | test_description="Test shutdown command" |
| 8 | |
| 9 | . lib/test-lib.sh |
| 10 | |
| 11 | test_init_ipfs |
| 12 | |
| 13 | test_launch_ipfs_daemon |
| 14 | |
| 15 | test_expect_success "shutdown succeeds" ' |
| 16 | ipfs shutdown |
| 17 | ' |
| 18 | |
| 19 | test_expect_success "daemon no longer running" ' |
| 20 | for i in $(test_seq 1 100) |
| 21 | do |
| 22 | go-sleep 100ms |
| 23 | ! kill -0 $IPFS_PID 2>/dev/null && return |
| 24 | done |
| 25 | ' |
| 26 | |
| 27 | test_launch_ipfs_daemon_without_network |
| 28 | |
| 29 | test_expect_success "shutdown succeeds" ' |
| 30 | ipfs shutdown |
| 31 | ' |
| 32 | |
| 33 | test_expect_success "daemon no longer running" ' |
| 34 | for i in $(test_seq 1 100) |
| 35 | do |
| 36 | go-sleep 100ms |
| 37 | ! kill -0 $IPFS_PID 2>/dev/null && return |
| 38 | done |
| 39 | ' |
| 40 | test_done |