github.com/whyrusleeping/gx@v0.14.3/tests/t0040-update.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 updating" 8 9 . lib/test-lib.sh 10 11 check_package_import() { 12 pkg=$1 13 imphash=$2 14 name=$3 15 16 test_expect_success "dir was created" ' 17 stat $pkg/vendor/gx/ipfs/$imphash > /dev/null 18 ' 19 20 test_expect_success "dep set in package.json" ' 21 jq -r ".gxDependencies[] | select(.hash == \"$imphash\") | .name" $pkg/package.json > name 22 ' 23 24 test_expect_success "name looks good" ' 25 echo "$name" > exp_name && 26 test_cmp exp_name name 27 ' 28 } 29 30 test_init_ipfs 31 test_launch_ipfs_daemon 32 33 # make a tree like this, then update C 34 # A 35 # |--B 36 # C | 37 # C 38 # 39 40 test_expect_success "setup test packages" ' 41 make_package a none 42 make_package b none 43 make_package c none 44 ' 45 46 test_expect_success "publish package c" ' 47 pkgC=$(publish_package c) 48 ' 49 50 test_expect_success "import package c from a succeeds" ' 51 pkg_run a gx import $pkgC 52 ' 53 54 check_package_import a $pkgC c 55 56 test_expect_success "import package c from b succeeds" ' 57 pkg_run b gx import $pkgC 58 ' 59 60 check_package_import b $pkgC c 61 62 test_expect_success "publish package b suceeds" ' 63 pkgB=$(publish_package b) 64 ' 65 66 test_expect_success "import package b succeeds" ' 67 pkg_run a gx import $pkgB 68 ' 69 70 check_package_import a $pkgB b 71 72 test_expect_success "change package c" ' 73 echo "test" > c/README.md && 74 pkg_run c gx version v1.2.0 && 75 pkgCnew=$(publish_package c) 76 ' 77 78 test_expect_success "should be a different hash" ' 79 test "$pkgC" != "$pkgCnew" 80 ' 81 82 test_expect_success "gx diff works" ' 83 echo n | gx diff "$pkgC" "$pkgCnew" >diff_out 84 ' 85 86 test_expect_success "gx diff output looks good" ' 87 cat >expected <<EOF && 88 PACKAGE c was changed from version 89 0.0.0 ($pkgC) 90 to 91 1.2.0 ($pkgCnew) 92 There were 0 changes in this packages dependencies. 93 view code changes for this package? [Y/n] 94 EOF 95 test_cmp expected diff_out 96 ' 97 98 test_expect_success "updating package c works" ' 99 pkg_run a gx update c $pkgCnew > update_out 100 ' 101 102 test_expect_success "update printed correct warning" ' 103 grep "dep b also imports c ($pkgC)" update_out 104 ' 105 106 test_expect_success "version was updated in package.json" ' 107 pkg_run a gx view c .version > vers_out 108 ' 109 110 test_expect_success "version output looks good" ' 111 echo "1.2.0" > vers_exp && 112 test_cmp vers_exp vers_out 113 ' 114 115 check_package_import a $pkgCnew c 116 117 test_kill_ipfs_daemon 118 119 test_done