t0040-add-and-cat.sh 1.94 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
#!/bin/sh
#
# Copyright (c) 2014 Christian Couder
# MIT Licensed; see the LICENSE file in this repository.
#

test_description="Test add and cat commands"

. ./test-lib.sh

11
test_launch_ipfs_mount
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 39 40

test_expect_success "ipfs add succeeds" '
	echo "Hello Worlds!" >mountdir/hello.txt &&
	ipfs add mountdir/hello.txt >actual
'

test_expect_success "ipfs add output looks good" '
	HASH="QmVr26fY1tKyspEJBniVhqxQeEjhF78XerGiqWAwraVLQH" &&
	echo "added $HASH $(pwd)/mountdir/hello.txt" >expected &&
	test_cmp expected actual
'

test_expect_success "ipfs cat succeeds" '
	ipfs cat $HASH >actual
'

test_expect_success "ipfs cat output looks good" '
	echo "Hello Worlds!" >expected &&
	test_cmp expected actual
'

test_expect_success "cat ipfs/stuff succeeds" '
	cat ipfs/$HASH >actual
'

test_expect_success "cat ipfs/stuff looks good" '
	test_cmp expected actual
'

41 42 43 44 45 46 47 48 49 50
test_expect_success "go-random is installed" '
	type random
'

test_expect_success "generate 100MB file using go-random" '
	random 104857600 42 >mountdir/bigfile
'

test_expect_success "sha1 of the file looks ok" '
	echo "54dc0dbbc353b2ffb745285793f89af0c9d98449  mountdir/bigfile" >sha1_expected &&
51
	shasum mountdir/bigfile >sha1_actual &&
52 53 54 55 56 57 58 59 60 61 62 63 64 65
	test_cmp sha1_expected sha1_actual
'

test_expect_success "ipfs add bigfile succeeds" '
	ipfs add mountdir/bigfile >actual
'

test_expect_success "ipfs add bigfile output looks good" '
	HASH="QmeZVkWkDu4W1vxWdDgUbqKYba9K3u45hJEdPA4Wr2sHZz" &&
	echo "added $HASH $(pwd)/mountdir/bigfile" >expected &&
	test_cmp expected actual
'

test_expect_success "ipfs cat succeeds" '
66
	ipfs cat $HASH | shasum >sha1_actual
67 68 69 70 71 72 73 74
'

test_expect_success "ipfs cat output looks good" '
	echo "54dc0dbbc353b2ffb745285793f89af0c9d98449  -" >sha1_expected &&
	test_cmp sha1_expected sha1_actual
'

test_expect_success "cat ipfs/bigfile succeeds" '
75
	cat ipfs/$HASH | shasum >sha1_actual
76 77 78 79 80 81
'

test_expect_success "cat ipfs/bigfile looks good" '
	test_cmp sha1_expected sha1_actual
'

82
test_kill_ipfs_mount
83 84

test_done