| 1 | #!/usr/bin/env bash |
| 2 | # |
| 3 | # Copyright (c) 2014 Christian Couder |
| 4 | # MIT Licensed; see the LICENSE file in this repository. |
| 5 | # |
| 6 | |
| 7 | test_description="Test init command with default config" |
| 8 | |
| 9 | . lib/test-lib.sh |
| 10 | |
| 11 | cfg_key="Addresses.API" |
| 12 | cfg_val="/ip4/0.0.0.0/tcp/5001" |
| 13 | |
| 14 | # test that init succeeds |
| 15 | test_expect_success "ipfs init succeeds" ' |
| 16 | export IPFS_PATH="$(pwd)/.ipfs" && |
| 17 | echo "IPFS_PATH: \"$IPFS_PATH\"" && |
| 18 | BITS="2048" && |
| 19 | ipfs init >actual_init || |
| 20 | test_fsh cat actual_init |
| 21 | ' |
| 22 | |
| 23 | test_expect_success ".ipfs/config has been created" ' |
| 24 | test -f "$IPFS_PATH"/config || |
| 25 | test_fsh ls -al .ipfs |
| 26 | ' |
| 27 | |
| 28 | test_expect_success "ipfs config succeeds" ' |
| 29 | ipfs config $cfg_flags "$cfg_key" "$cfg_val" |
| 30 | ' |
| 31 | |
| 32 | test_expect_success "ipfs read config succeeds" ' |
| 33 | IPFS_DEFAULT_CONFIG=$(cat "$IPFS_PATH"/config) |
| 34 | ' |
| 35 | |
| 36 | test_expect_success "clean up ipfs dir" ' |
| 37 | rm -rf "$IPFS_PATH" |
| 38 | ' |
| 39 | |
| 40 | test_expect_success "ipfs init default config succeeds" ' |
| 41 | echo $IPFS_DEFAULT_CONFIG | ipfs init - >actual_init || |
| 42 | test_fsh cat actual_init |
| 43 | ' |
| 44 | |
| 45 | test_expect_success "ipfs config output looks good" ' |
| 46 | echo "$cfg_val" >expected && |
| 47 | ipfs config "$cfg_key" >actual && |
| 48 | test_cmp expected actual |
| 49 | ' |
| 50 | |
| 51 | test_done |