github.com/whyrusleeping/gx@v0.14.3/tests/t0010-init.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="QmWse21QGcW3vnsf2PE2eCaJgM5Lb2GrCbFE23yvixsS8H" 15 16 test_expect_success "setup test package" ' 17 which gx && 18 mkdir mypkg && 19 echo "{\"User\":{\"Name\":\"gxguy <gxguy@gx.io>\"}}" > mypkg/.gxrc && 20 (cd mypkg && gx init --lang=none && 21 pkg=$(cat package.json) && echo "$pkg" | jq "del(.gxVersion)" > package.json) 22 ' 23 24 test_expect_success "author string intact" ' 25 grep "gxguy <gxguy@gx.io>" mypkg/package.json 26 ' 27 28 test_expect_success "package.json has right values" ' 29 NAME=$(jq -r .name mypkg/package.json) && 30 PKGLANG=$(jq -r .language mypkg/package.json) 31 PKGVERS=$(jq -r .version mypkg/package.json) 32 ' 33 34 test_expect_success "values look correct" ' 35 test $NAME = "mypkg" && 36 test $PKGLANG = "none" && 37 test $PKGVERS = "0.0.0" 38 ' 39 40 test_expect_success "publish package works" ' 41 pkg_run mypkg gx publish > pub_out 42 ' 43 44 test_expect_success "publish output looks good" ' 45 echo "package mypkg published with hash: $pkg_hash" > expected && 46 test_cmp expected pub_out 47 ' 48 49 test_expect_success ".gx dir was created" ' 50 test -d mypkg/.gx 51 ' 52 53 test_expect_success "lastpubver looks good" ' 54 echo "0.0.0: $pkg_hash" > lpv_exp && 55 test_cmp lpv_exp mypkg/.gx/lastpubver 56 ' 57 58 test_expect_success "publish package second time fails" ' 59 test_expect_code 1 pkg_run mypkg gx publish > pub_out_fail 60 ' 61 62 test_expect_success "failure message wants changed version" ' 63 echo "ERROR: please update your packages version before publishing. (use -f to skip)" > exp_fail && 64 test_cmp exp_fail pub_out_fail 65 ' 66 67 test_expect_success "publish package -f second time succeeds" ' 68 pkg_run mypkg gx publish -f > pub_out2 69 ' 70 71 test_expect_success "publish output is the same on second publish" ' 72 test_cmp expected pub_out2 73 ' 74 75 test_kill_ipfs_daemon 76 77 test_done