From e96416dea6a3ac23ba95d7fcd33e5325e7e2888e Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Sat, 29 Jun 2019 11:10:31 +0200 Subject: [PATCH] test: test operations when the API file is stale --- test/sharness/t0064-api-file.sh | 100 ++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100755 test/sharness/t0064-api-file.sh diff --git a/test/sharness/t0064-api-file.sh b/test/sharness/t0064-api-file.sh new file mode 100755 index 00000000000..97c1a7b239c --- /dev/null +++ b/test/sharness/t0064-api-file.sh @@ -0,0 +1,100 @@ +#!/usr/bin/env bash +# +# MIT Licensed; see the LICENSE file in this repository. +# + +test_description="Test api file" + +. lib/test-lib.sh + +test_init_ipfs + + +test_launch_ipfs_daemon +test_kill_ipfs_daemon + +test_expect_success "version always works" ' + ipfs version >/dev/null +' + +test_expect_success "swarm peers fails when offline" ' + test_must_fail ipfs swarm peers >/dev/null +' + +test_expect_success "swarm peers fails when offline and API specified" ' + test_must_fail ipfs swarm peers --api="$API_MADDR" >/dev/null +' + +test_expect_success "pin ls succeeds when offline" ' + ipfs pin ls >/dev/null +' + +test_expect_success "pin ls fails when offline and API specified" ' + test_must_fail ipfs pin ls --api="$API_MADDR" >/dev/null +' + +test_expect_success "id succeeds when offline" ' + ipfs id >/dev/null +' + +test_expect_success "id fails when offline API specified" ' + test_must_fail ipfs id --api="$API_MADDR" >/dev/null +' + +test_expect_success "create API file" ' + echo "$API_MADDR" > "$IPFS_PATH/api" +' + +test_expect_success "version always works" ' + ipfs version >/dev/null +' + +test_expect_success "id succeeds when offline and API file exists" ' + ipfs id >/dev/null +' + +test_expect_success "pin ls succeeds when offline and API file exists" ' + ipfs pin ls >/dev/null +' + +test_launch_ipfs_daemon + +test_expect_success "version always works" ' + ipfs version >/dev/null +' + +test_expect_success "id succeeds when online" ' + ipfs id >/dev/null +' + +test_expect_success "swarm peers succeeds when online" ' + ipfs swarm peers >/dev/null +' + +test_expect_success "pin ls succeeds when online" ' + ipfs pin ls >/dev/null +' + +test_expect_success "remove API file when daemon is running" ' + rm "$IPFS_PATH/api" +' + +test_expect_success "version always works" ' + ipfs version >/dev/null +' + +test_expect_success "swarm peers fails when the API file is missing" ' + test_must_fail ipfs swarm peers >/dev/null +' + +test_expect_success "id fails when daemon is running but API file is missing (locks repo)" ' + test_must_fail ipfs pin ls >/dev/null +' + +test_expect_success "pin ls fails when daemon is running but API file is missing (locks repo)" ' + test_must_fail ipfs pin ls >/dev/null +' + +test_kill_ipfs_daemon + +test_done