master
sh 38 lines 809 Bytes
Raw
1 #!/usr/bin/env bash
2 #
3 # Copyright (c) 2015 Jeromy Johnson
4 # MIT Licensed; see the LICENSE file in this repository.
5 #
6
7 test_description="Test output of streaming json commands"
8
9 . lib/test-lib.sh
10
11 test_init_ipfs
12
13 get_api_port() {
14 cat "$IPFS_PATH/api" | awk -F/ '{ print $5 }'
15 }
16
17 test_ls_cmd() {
18 test_expect_success "make a file with multiple refs" '
19 HASH=$(random-data -size=1000000 | ipfs add -q)
20 '
21
22 test_expect_success "can get refs through curl" '
23 PORT=$(get_api_port) &&
24 curl http://localhost:$PORT/api/v0/refs/$HASH > output
25 '
26
27 # make sure newlines are printed between each object
28 test_expect_success "output looks good" '
29 test_expect_code 1 grep "}{" output > /dev/null
30 '
31 }
32
33 # should work online (only)
34 test_launch_ipfs_daemon
35 test_ls_cmd
36 test_kill_ipfs_daemon
37
38 test_done