t0022-init-default.sh 1.17 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
#!/bin/sh
#
# Copyright (c) 2014 Christian Couder
# MIT Licensed; see the LICENSE file in this repository.
#

test_description="Test init command with default config"

. lib/test-lib.sh

cfg_key="Addresses.API"
cfg_val="/ip4/0.0.0.0/tcp/5001"

# test that init succeeds
test_expect_success "ipfs init succeeds" '
	export IPFS_PATH="$(pwd)/.ipfs" &&
	echo "IPFS_PATH: \"$IPFS_PATH\"" &&
	BITS="2048" &&
	ipfs init --bits="$BITS" >actual_init ||
	test_fsh cat actual_init
'

test_expect_success ".ipfs/config has been created" '
	test -f "$IPFS_PATH"/config ||
	test_fsh ls -al .ipfs
'

test_expect_success "ipfs config succeeds" '
	ipfs config $cfg_flags "$cfg_key" "$cfg_val"
'

test_expect_success "ipfs read config succeeds" '
    IPFS_DEFAULT_CONFIG=$(cat "$IPFS_PATH"/config)
'

test_expect_success "clean up ipfs dir" '
	rm -rf "$IPFS_PATH"
'

test_expect_success "ipfs init default config succeeds" '
	echo $IPFS_DEFAULT_CONFIG | ipfs init - >actual_init ||
	test_fsh cat actual_init
'

test_expect_success "ipfs config output looks good" '
	echo "$cfg_val" >expected &&
	ipfs config "$cfg_key" >actual &&
	test_cmp expected actual
'

test_launch_ipfs_daemon

test_kill_ipfs_daemon

test_done