From 60ad7a5afc7059e418755d3ffcd194eca857a47e Mon Sep 17 00:00:00 2001
From: Jeromy <jeromyj@gmail.com>
Date: Tue, 23 Jun 2015 09:04:31 -0700
Subject: [PATCH] sharness tests for --only-hash

License: MIT
Signed-off-by: Jeromy <jeromyj@gmail.com>
---
 test/sharness/t0040-add-and-cat.sh     |  8 ++++++++
 test/sharness/t0041-add-cat-offline.sh | 14 ++++++++++++++
 2 files changed, 22 insertions(+)

diff --git a/test/sharness/t0040-add-and-cat.sh b/test/sharness/t0040-add-and-cat.sh
index 03cdb75d4..0e3e6fb08 100755
--- a/test/sharness/t0040-add-and-cat.sh
+++ b/test/sharness/t0040-add-and-cat.sh
@@ -39,6 +39,14 @@ test_expect_success "ipfs add output looks good" '
 	test_cmp expected actual
 '
 
+test_expect_success "ipfs add --only-hash succeeds" '
+	ipfs add --only-hash mountdir/hello.txt > oh_actual
+'
+
+test_expect_success "ipfs add --only-hash output looks good" '
+	ipfs add --only-hash mountdir/hello.txt > oh_actual
+'
+
 test_expect_success "ipfs cat succeeds" '
 	ipfs cat "$HASH" >actual
 '
diff --git a/test/sharness/t0041-add-cat-offline.sh b/test/sharness/t0041-add-cat-offline.sh
index cb370eec0..a8c0e36a6 100755
--- a/test/sharness/t0041-add-cat-offline.sh
+++ b/test/sharness/t0041-add-cat-offline.sh
@@ -15,6 +15,20 @@ test_expect_success "ipfs add file succeeds" '
 	HASH=$(ipfs add -q afile)
 '
 
+test_expect_success "ipfs add output looks good" '
+	echo Qmb1EXrDyKhNWfvLPYK4do3M9nU7BuLAcbqBir6aUrDsRY > expected &&
+	echo $HASH > actual &&
+	test_cmp expected actual
+'
+
+test_expect_success "ipfs add --only-hash succeeds" '
+	ipfs add -q --only-hash afile > ho_output
+'
+
+test_expect_success "ipfs add --only-hash output looks good" '
+	test_cmp expected ho_output
+'
+
 test_expect_success "ipfs cat file suceeds" '
 	ipfs cat $HASH > out_1
 '
-- 
GitLab