t0231-channel-streaming.sh 772 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
#!/bin/sh
#
# Copyright (c) 2015 Jeromy Johnson
# MIT Licensed; see the LICENSE file in this repository.
#

test_description="Test output of streaming json commands"

. lib/test-lib.sh

test_init_ipfs

get_api_port() {
	cat "$IPFS_PATH/api" | awk -F/ '{ print $5 }'
}

test_ls_cmd() {
	test_expect_success "make a file with multiple refs" '
		HASH=$(random 1000000 | ipfs add -q)
	'

	test_expect_success "can get refs through curl" '
		PORT=$(get_api_port) &&
		curl http://localhost:$PORT/api/v0/refs/$HASH > output
	'

	# make sure newlines are printed between each object
	test_expect_success "output looks good" '
		test_expect_code 1 grep "}{" output > /dev/null
	'
}

# should work online (only)
test_launch_ipfs_daemon
test_ls_cmd
test_kill_ipfs_daemon

test_done