github.com/whyrusleeping/gx@v0.14.3/tests/t0015-config.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 package init"
     8  
     9  . lib/test-lib.sh
    10  
    11  test_init_ipfs
    12  test_launch_ipfs_daemon
    13  
    14  pkg_hash="QmXmwLTAxcfSeAXnq6KVsRPTjsJBAvuYnhqqLUrnUyTVNh"
    15  
    16  test_expect_success "setup test package" '
    17  	which gx &&
    18  	mkdir mypkg &&
    19  	echo "{\"User\":{\"Name\":\"gxguy\"}}" > mypkg/.gxrc &&
    20  	(cd mypkg && gx init --lang=none)
    21  '
    22  
    23  set_package_field() {
    24  	local field="$1"
    25  	local val="$2"
    26  	cat mypkg/package.json | jq "$field = $val" > temp &&
    27  	mv temp mypkg/package.json
    28  	return $?
    29  }
    30  
    31  test_expect_success "add a field to the package.json" '
    32  	set_package_field .cats "\"awesome\""
    33  '
    34  
    35  test_expect_success "update version" '
    36  	(cd mypkg && gx version 0.4.9)
    37  '
    38  
    39  test_expect_success "extra config val remains" '
    40  	cat mypkg/package.json | jq -e .cats > out
    41  '
    42  
    43  test_expect_success "output looks good" '
    44  	echo "\"awesome\"" > exp &&
    45  	test_cmp exp out
    46  '
    47  
    48  test_kill_ipfs_daemon
    49  
    50  test_done