@cryptotaxi247 / kubo / commits / 980e34148

Add tests for "ls --resolve-type=false".

License: MIT Signed-off-by: Kevin Atkinson <k@kevina.org>

Kevin Atkinson committed Jan 3, 2017 at 21:19 UTC 980e3414896f364c5dac711924200d08bf79849d
1 file changed +55
test/sharness/t0045-ls.sh
+55
@@ -111,4 +111,59 @@ test_ls_cmd
111 test_ls_cmd_raw_leaves
112 test_kill_ipfs_daemon
113
114 +#
115 +# test for ls --resolve-type=false
116 +#
117 +
118 +test_expect_success "'ipfs add -r' succeeds" '
119 + mkdir adir &&
120 + # note: not using a seed as the files need to have truly random content
121 + random 1000 > adir/file1 &&
122 + random 1000 > adir/file2 &&
123 + ipfs add --pin=false -q -r adir > adir-hashes
124 +'
125 +
126 +test_expect_success "get hashes from add output" '
127 + FILE=`head -1 adir-hashes` &&
128 + DIR=`tail -1 adir-hashes` &&
129 + test "$FILE" -a "$DIR"
130 +'
131 +
132 +test_expect_success "remove a file in dir" '
133 + ipfs block rm $FILE
134 +'
135 +
136 +test_expect_success "'ipfs ls --resolve-type=false ' ok" '
137 + ipfs ls --resolve-type=false $DIR > /dev/null
138 +'
139 +
140 +test_expect_success "'ipfs ls' fails" '
141 + test_must_fail ipfs ls $DIR
142 +'
143 +
144 +test_launch_ipfs_daemon --offline
145 +
146 +test_expect_success "'ipfs ls --resolve-type=false' ok" '
147 + ipfs ls --resolve-type=false $DIR > /dev/null
148 +'
149 +
150 +test_expect_success "'ipfs ls' fails" '
151 + test_must_fail ipfs ls $DIR
152 +'
153 +
154 +test_kill_ipfs_daemon
155 +
156 +test_launch_ipfs_daemon
157 +
158 +# now we try `ipfs ls --resolve-type=false` with the daemon online It
159 +# should not even attempt to retrieve the file from the network. If
160 +# it does it should eventually fail as the content is random and
161 +# should not exist on the network, but we don't want to wait for a
162 +# timeout so we will kill the request after a few seconds
163 +test_expect_success "'ipfs ls --resolve-type=false' ok and does not hang" '
164 + go-timeout 2 ipfs ls --resolve-type=false $DIR
165 +'
166 +
167 +test_kill_ipfs_daemon
168 +
169 test_done