github.com/zignig/go-ipfs@v0.0.0-20141111235910-c9e5fdf55a52/test/t0040-add-and-cat.sh (about)

     1  #!/bin/sh
     2  #
     3  # Copyright (c) 2014 Christian Couder
     4  # MIT Licensed; see the LICENSE file in this repository.
     5  #
     6  
     7  test_description="Test add and cat commands"
     8  
     9  . lib/test-lib.sh
    10  
    11  test_launch_ipfs_mount
    12  
    13  test_expect_success "ipfs add succeeds" '
    14  	echo "Hello Worlds!" >mountdir/hello.txt &&
    15  	ipfs add mountdir/hello.txt >actual
    16  '
    17  
    18  test_expect_success "ipfs add output looks good" '
    19  	HASH="QmVr26fY1tKyspEJBniVhqxQeEjhF78XerGiqWAwraVLQH" &&
    20  	echo "added $HASH $(pwd)/mountdir/hello.txt" >expected &&
    21  	test_cmp expected actual
    22  '
    23  
    24  test_expect_success "ipfs cat succeeds" '
    25  	ipfs cat $HASH >actual
    26  '
    27  
    28  test_expect_success "ipfs cat output looks good" '
    29  	echo "Hello Worlds!" >expected &&
    30  	test_cmp expected actual
    31  '
    32  
    33  test_expect_success FUSE "cat ipfs/stuff succeeds" '
    34  	cat ipfs/$HASH >actual
    35  '
    36  
    37  test_expect_success FUSE "cat ipfs/stuff looks good" '
    38  	test_cmp expected actual
    39  '
    40  
    41  test_expect_success "go-random is installed" '
    42  	type random
    43  '
    44  
    45  test_expect_success "generate 100MB file using go-random" '
    46  	random 104857600 42 >mountdir/bigfile
    47  '
    48  
    49  test_expect_success "sha1 of the file looks ok" '
    50  	echo "ae986dd159e4f014aee7409cdc2001ea74f618d1  mountdir/bigfile" >sha1_expected &&
    51  	shasum mountdir/bigfile >sha1_actual &&
    52  	test_cmp sha1_expected sha1_actual
    53  '
    54  
    55  test_expect_success "ipfs add bigfile succeeds" '
    56  	ipfs add mountdir/bigfile >actual
    57  '
    58  
    59  test_expect_success "ipfs add bigfile output looks good" '
    60  	HASH="QmVm3Da371opC3hpsCLuYSozdyM6wRvu9UoUqoyW8u4LRq" &&
    61  	echo "added $HASH $(pwd)/mountdir/bigfile" >expected &&
    62  	test_cmp expected actual
    63  '
    64  
    65  test_expect_success "ipfs cat succeeds" '
    66  	ipfs cat $HASH | shasum >sha1_actual
    67  '
    68  
    69  test_expect_success "ipfs cat output looks good" '
    70  	echo "ae986dd159e4f014aee7409cdc2001ea74f618d1  -" >sha1_expected &&
    71  	test_cmp sha1_expected sha1_actual
    72  '
    73  
    74  test_expect_success FUSE "cat ipfs/bigfile succeeds" '
    75  	cat ipfs/$HASH | shasum >sha1_actual
    76  '
    77  
    78  test_expect_success FUSE "cat ipfs/bigfile looks good" '
    79  	test_cmp sha1_expected sha1_actual
    80  '
    81  
    82  test_kill_ipfs_mount
    83  
    84  test_done