small sharness test for promise failure checking
License: MIT Signed-off-by: Jeromy <why@ipfs.io>
Jeromy committed
Apr 12, 2016 at 11:06 UTC
5a0b6e593afadd4efba0c2c90684f9cbc1ce76ef
1 file changed
+21
test/sharness/t0090-get.sh
+21
@@ -113,9 +113,30 @@ test_get_cmd() {
113
'
114
}
115
116
+test_get_fail() {
117
+ test_expect_success "create an object that has unresolveable links" '
118
+ cat <<-\EOF >bad_object &&
119
+{ "Links": [ { "Name": "foo", "Hash": "QmZzaC6ydNXiR65W8VjGA73ET9MZ6VFAqUT1ngYMXcpihn", "Size": 1897 }, { "Name": "bar", "Hash": "Qmd4mG6pDFDmDTn6p3hX1srP8qTbkyXKj5yjpEsiHDX3u8", "Size": 56 }, { "Name": "baz", "Hash": "QmUTjwRnG28dSrFFVTYgbr6LiDLsBmRr2SaUSTGheK2YqG", "Size": 24266 } ], "Data": "\b\u0001" }
120
+ EOF
121
+ cat bad_object | ipfs object put > put_out
122
+ '
123
+
124
+ test_expect_success "output looks good" '
125
+ echo "added QmaGidyrnX8FMbWJoxp8HVwZ1uRKwCyxBJzABnR1S2FVUr" > put_exp &&
126
+ test_cmp put_exp put_out
127
+ '
128
+
129
+ test_expect_success "ipfs get fails" '
130
+ test_expect_code 1 ipfs get QmaGidyrnX8FMbWJoxp8HVwZ1uRKwCyxBJzABnR1S2FVUr
131
+ '
132
+}
133
+
134
# should work offline
135
test_get_cmd
136
137
+# only really works offline, will try and search network when online
138
+test_get_fail
139
+
140
# should work online
141
test_launch_ipfs_daemon
142
test_get_cmd