t0051: check json i/o
License: MIT Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Christian Couder committed
Aug 23, 2015 at 02:03 UTC
5cced6f21abc763341f3521147d78caa832dbd4d
1 file changed
+21
-1
test/sharness/t0051-object.sh
+21
-1
@@ -59,7 +59,7 @@ test_object_cmd() {
59
echo "CumulativeSize: 18" >> expected_stat &&
60
test_cmp expected_stat actual_stat
61
'
62
-
62
+
63
test_expect_success "'ipfs object put file.json' succeeds" '
64
ipfs object put ../t0051-object-data/testPut.json > actual_putOut
65
'
@@ -111,6 +111,26 @@ test_object_cmd() {
111
test_cmp expected_putBrokenErr actual_putBrokenErr
112
'
113
114
+ test_expect_success "setup: add UTF-8 test file" '
115
+ HASH="QmNY5sQeH9ttVCg24sizH71dNbcZTpGd7Yb3YwsKZ4jiFP" &&
116
+ ipfs add ../t0051-object-data/UTF-8-test.txt >actual &&
117
+ echo "added $HASH UTF-8-test.txt" >expected &&
118
+ test_cmp expected actual
119
+ '
120
+
121
+ test_expect_success "'ipfs object get --enc=json' succeeds" '
122
+ ipfs object get --enc=json $HASH >utf8_json
123
+ '
124
+
125
+ test_expect_success "'ipfs object put --inputenc=json' succeeds" '
126
+ ipfs object put --inputenc=json <utf8_json >actual
127
+ '
128
+
129
+ test_expect_failure "'ipfs object put --inputenc=json' output looks good" '
130
+ echo "added $HASH" >expected &&
131
+ test_cmp expected actual
132
+ '
133
+
134
test_expect_success "'ipfs object patch' should work" '
135
EMPTY_DIR=$(ipfs object new unixfs-dir) &&
136
OUTPUT=$(ipfs object patch $EMPTY_DIR add-link foo $EMPTY_DIR)