test the ipfs cat --length flag
License: MIT Signed-off-by: Steven Allen <steven@stebalien.com>
Steven Allen committed
Jan 5, 2018 at 18:22 UTC
089496b918e495cf0599bcce87acfb94395f6de0
1 file changed
+50
test/sharness/t0040-add-and-cat.sh
+50
@@ -78,6 +78,56 @@ test_add_cat_file() {
78
test_expect_code 1 ipfs cat --offset -102 "$HASH" > actual
79
'
80
81
+ test_expect_success "ipfs cat with length succeeds" '
82
+ ipfs cat --length 8 "$HASH" >actual
83
+ '
84
+
85
+ test_expect_success "ipfs cat with length output looks good" '
86
+ echo -n "Hello Wo" >expected &&
87
+ test_cmp expected actual
88
+ '
89
+
90
+ test_expect_success "ipfs cat multiple hashes with offset and length succeeds" '
91
+ ipfs cat --offset 5 --length 15 "$HASH" "$HASH" "$HASH" >actual
92
+ '
93
+
94
+ test_expect_success "ipfs cat multiple hashes with offset and length looks good" '
95
+ echo " Worlds!" >expected &&
96
+ echo -n "Hello " >>expected &&
97
+ test_cmp expected actual
98
+ '
99
+
100
+ test_expect_success "ipfs cat with exact length succeeds" '
101
+ ipfs cat --length $(ipfs cat "$HASH" | wc -c) "$HASH" >actual
102
+ '
103
+
104
+ test_expect_success "ipfs cat with exact length looks good" '
105
+ echo "Hello Worlds!" >expected &&
106
+ test_cmp expected actual
107
+ '
108
+
109
+ test_expect_success "ipfs cat with 0 length succeeds" '
110
+ ipfs cat --length 0 "$HASH" >actual
111
+ '
112
+
113
+ test_expect_success "ipfs cat with 0 length looks good" '
114
+ : >expected &&
115
+ test_cmp expected actual
116
+ '
117
+
118
+ test_expect_success "ipfs cat with oversized length succeeds" '
119
+ ipfs cat --length 100 "$HASH" >actual
120
+ '
121
+
122
+ test_expect_success "ipfs cat with oversized length looks good" '
123
+ echo "Hello Worlds!" >expected &&
124
+ test_cmp expected actual
125
+ '
126
+
127
+ test_expect_success "ipfs cat with negitive length should fail" '
128
+ test_expect_code 1 ipfs cat --length -102 "$HASH" > actual
129
+ '
130
+
131
test_expect_success "ipfs cat /ipfs/file succeeds" '
132
ipfs cat /ipfs/$HASH >actual
133
'