github.com/keltia/go-ipfs@v0.3.8-0.20150909044612-210793031c63/test/sharness/t0100-name.sh (about)

     1  #!/bin/sh
     2  #
     3  # Copyright (c) 2014 Jeromy Johnson
     4  # MIT Licensed; see the LICENSE file in this repository.
     5  #
     6  
     7  test_description="Test ipfs repo operations"
     8  
     9  . lib/test-lib.sh
    10  
    11  test_init_ipfs
    12  
    13  # test publishing a hash
    14  
    15  test_expect_success "'ipfs name publish' succeeds" '
    16  	PEERID=`ipfs id --format="<id>"` &&
    17  	ipfs name publish "/ipfs/$HASH_WELCOME_DOCS" >publish_out
    18  '
    19  
    20  test_expect_success "publish output looks good" '
    21  	echo "Published to ${PEERID}: /ipfs/$HASH_WELCOME_DOCS" >expected1 &&
    22  	test_cmp publish_out expected1
    23  '
    24  
    25  test_expect_success "'ipfs name resolve' succeeds" '
    26  	ipfs name resolve "$PEERID" >output
    27  '
    28  
    29  test_expect_success "resolve output looks good" '
    30  	printf "/ipfs/%s" "$HASH_WELCOME_DOCS" >expected2 &&
    31  	test_cmp output expected2
    32  '
    33  
    34  # now test with a path
    35  
    36  test_expect_success "'ipfs name publish' succeeds" '
    37  	PEERID=`ipfs id --format="<id>"` &&
    38  	ipfs name publish "/ipfs/$HASH_WELCOME_DOCS/help" >publish_out
    39  '
    40  
    41  test_expect_success "publish a path looks good" '
    42  	echo "Published to ${PEERID}: /ipfs/$HASH_WELCOME_DOCS/help" >expected3 &&
    43  	test_cmp publish_out expected3
    44  '
    45  
    46  test_expect_success "'ipfs name resolve' succeeds" '
    47  	ipfs name resolve "$PEERID" >output
    48  '
    49  
    50  test_expect_success "resolve output looks good" '
    51  	printf "/ipfs/%s/help" "$HASH_WELCOME_DOCS" >expected4 &&
    52  	test_cmp output expected4
    53  '
    54  
    55  # publish with an explicit node ID
    56  
    57  test_expect_success "'ipfs name publish <local-id> <hash>' succeeds" '
    58  	PEERID=`ipfs id --format="<id>"` &&
    59  	ipfs name publish "${PEERID}" "/ipfs/$HASH_WELCOME_DOCS" >actual_node_id_publish
    60  '
    61  
    62  test_expect_success "publish with our explicit node ID looks good" '
    63  	echo "Published to ${PEERID}: /ipfs/$HASH_WELCOME_DOCS" >expected_node_id_publish &&
    64  	test_cmp expected_node_id_publish actual_node_id_publish
    65  '
    66  
    67  test_done