From 64677e75a3ea3560438a7ee3984fa571f4d8489e Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Wed, 18 May 2016 06:58:38 +0200 Subject: [PATCH] Add sharness tests for files stat format options License: MIT Signed-off-by: Jakub Sztandera --- test/sharness/t0250-files-api.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/test/sharness/t0250-files-api.sh b/test/sharness/t0250-files-api.sh index 33a5f08d9..676d5b3be 100755 --- a/test/sharness/t0250-files-api.sh +++ b/test/sharness/t0250-files-api.sh @@ -64,6 +64,36 @@ test_files_api() { test_expect_success "directory is empty" ' verify_dir_contents /cats ' + # we do verification of stat formatting now as we depend on it + + test_expect_success "stat works" ' + ipfs files stat / >stat + ' + + test_expect_success "hash is first line of stat" ' + ipfs ls $(head -1 stat) | grep "cats" + ' + + test_expect_success "stat --hash gives only hash" ' + ipfs files stat --hash / >actual && + head -1 stat >expected && + test_cmp expected actual + ' + + test_expect_success "stat with multiple format options should fail" ' + test_must_fail ipfs files stat --hash --size / + ' + + test_expect_success "compare hash option with format" ' + ipfs files stat --hash / >expected && + ipfs files stat --format='"'"''"'"' / >actual && + test_cmp expected actual + ' + test_expect_success "compare size option with format" ' + ipfs files stat --size / >expected && + ipfs files stat --format='"'"''"'"' / >actual && + test_cmp expected actual + ' test_expect_success "check root hash" ' ipfs files stat / | head -n1 > roothash