github.com/whyrusleeping/gx@v0.14.3/tests/t0050-hooks.sh (about)

     1  #!/bin/sh
     2  #
     3  # Copyright (c) 2016 Jeromy Johnson
     4  # MIT Licensed; see the LICENSE file in this repository.
     5  #
     6  
     7  test_description="test gx hooks"
     8  
     9  . lib/test-lib.sh
    10  
    11  
    12  test_init_ipfs
    13  test_launch_ipfs_daemon
    14  
    15  test_expect_success "init a package" '
    16  	mkdir a &&
    17  	pkg_run a gx init --lang=test 2> init_out
    18  '
    19  
    20  test_expect_success "post init was run" '
    21  	echo "HOOK RUN: post-init $(pwd)/a" > init_exp &&
    22  	test_cmp init_exp init_out
    23  '
    24  
    25  test_expect_success "publish a package" '
    26  	pkg_hash=$(publish_package a 2> publish_out)
    27  '
    28  
    29  test_expect_success "pre and post publish hooks ran" '
    30  	echo "HOOK RUN: pre-publish " > publish_exp &&
    31  	echo "HOOK RUN: post-publish $pkg_hash" >> publish_exp  &&
    32  	test_cmp publish_exp publish_out
    33  '
    34  
    35  test_expect_success "create another package" '
    36  	make_package b
    37  '
    38  
    39  test_expect_success "import a from b locally" '
    40  	pkg_run b gx import --local $pkg_hash 2> import_out
    41  '
    42  
    43  test_expect_success "output looks good" '
    44  	echo "HOOK RUN: post-install vendor/gx/ipfs/$pkg_hash" > import_exp &&
    45  	echo "HOOK RUN: post-import $pkg_hash" >> import_exp &&
    46  	test_cmp import_exp import_out
    47  '
    48  
    49  test_expect_success "create another package" '
    50  	make_package c
    51  '
    52  
    53  test_expect_success "import a globally from c" '
    54  	pkg_run c gx import --global $pkg_hash 2> import_out
    55  '
    56  
    57  test_expect_success "output looks good" '
    58  	echo "HOOK RUN: post-install vendor/gx/ipfs/$pkg_hash --global" > import_exp &&
    59  	echo "HOOK RUN: post-import $pkg_hash" >> import_exp &&
    60  	test_cmp import_exp import_out
    61  '
    62  
    63  test_kill_ipfs_daemon
    64  
    65  test_done