diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2013-10-20 12:43:41 +0200 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2013-10-20 12:43:41 +0200 |
commit | d2e3a3795f345fd78ead2cf06b1134b46f9d4bc4 (patch) | |
tree | f688a32d667bc2c44ef994d4a1895911758add61 /test | |
parent | dc180da2125df5eb8953ee98123ba7d73b676ff6 (diff) | |
download | app.sh-d2e3a3795f345fd78ead2cf06b1134b46f9d4bc4.tar.gz app.sh-d2e3a3795f345fd78ead2cf06b1134b46f9d4bc4.tar.bz2 app.sh-d2e3a3795f345fd78ead2cf06b1134b46f9d4bc4.tar.xz app.sh-d2e3a3795f345fd78ead2cf06b1134b46f9d4bc4.zip |
o Getting app-cat-conf to read from ~/.appconfig too.
Diffstat (limited to 'test')
-rwxr-xr-x | test/app-cat-conf.bats | 36 | ||||
-rwxr-xr-x | test/app-conf.bats | 2 | ||||
-rwxr-xr-x | test/app-init.bats | 25 | ||||
-rw-r--r-- | test/data/app-cat-conf/config-4 | 1 | ||||
-rw-r--r-- | test/data/app-cat-conf/home/.appconfig | 2 | ||||
-rw-r--r-- | test/data/app-cat-conf/my-app/.app/config | 2 | ||||
-rw-r--r-- | test/utils.bash | 3 |
7 files changed, 65 insertions, 6 deletions
diff --git a/test/app-cat-conf.bats b/test/app-cat-conf.bats index 8060cea..62309a5 100755 --- a/test/app-cat-conf.bats +++ b/test/app-cat-conf.bats @@ -43,21 +43,55 @@ setup_inner() { @test "app-cat-conf can use stdin and multiple files" { x=$(cat $APPSH_HOME/test/data/app-cat-conf/config-3 | \ - $APPSH_HOME/libexec/app-cat-conf -D -f $APPSH_HOME/test/data/app-cat-conf/config-2 -f -) + $APPSH_HOME/libexec/app-cat-conf -D -f - -f $APPSH_HOME/test/data/app-cat-conf/config-2) [[ $x == "foo.bar=wat foo.wat=bar" ]] } +@test "app-cat-conf read multiple files, last file wins" { + app_libexec app-cat-conf \ + -f $APPSH_HOME/test/data/app-cat-conf/config-2 \ + -f $APPSH_HOME/test/data/app-cat-conf/config-4 + echo_lines + eq '${lines[0]}' "foo.bar=foo" + eq '${#lines[*]}' 1 +} + @test "uses \$APPSH_DEFAULT_CONFIG" { APPSH_DEFAULT_CONFIG=$APPSH_HOME/test/data/app-cat-conf/config-2 app_libexec app-cat-conf -f /dev/null echo_lines eq '${lines[0]}' "foo.bar=wat" eq '${#lines[*]}' 1 +} +@test "uses \$APPSH_DEFAULT_CONFIG, check order" { app_libexec app-cat-conf -f $APPSH_HOME/test/data/app-cat-conf/config-3 echo_lines eq '${lines[0]}' "foo.bar=baz" eq '${lines[1]}' "foo.wat=bar" eq '${#lines[*]}' 2 } + +@test "app-cat-conf read from installation's, user's and then app's config" { + HOME=$APPSH_HOME/test/data/app-cat-conf/home + APPSH_DEFAULT_CONFIG=$APPSH_HOME/test/data/app-cat-conf/config-2 + app_libexec app-cat-conf; echo_lines + eq '$status' 0 + eq '${lines[0]}' "foo.bar=1" + eq '${lines[1]}' "foo.foo=2" + eq '${#lines[*]}' 2 +} + +# With home directory, outside app +@test "./app conf - should read user's conf too, in app" { + HOME=$APPSH_HOME/test/data/app-cat-conf/home + APPSH_DEFAULT_CONFIG=$APPSH_HOME/test/data/app-cat-conf/config-2 + cd $APPSH_HOME/test/data/app-cat-conf/my-app + app_libexec app-cat-conf; echo_lines + eq '$status' 0 + eq '${lines[0]}' "foo.bar=2" + eq '${lines[1]}' "foo.baz=3" + eq '${lines[2]}' "foo.foo=2" + eq '${#lines[*]}' 3 +} diff --git a/test/app-conf.bats b/test/app-conf.bats index 13dc18b..c95a133 100755 --- a/test/app-conf.bats +++ b/test/app-conf.bats @@ -134,7 +134,7 @@ setup_inner() { eq '${lines[0]}' "Importing config from config-b" eq '${#lines[*]}' 1 - app_libexec app-cat-conf + app_libexec app-cat-conf; echo_lines eq '${lines[0]}' "foo.bar=2" eq '${lines[1]}' "foo.baz=1" eq '${#lines[*]}' 2 diff --git a/test/app-init.bats b/test/app-init.bats index ebf850c..db681a1 100755 --- a/test/app-init.bats +++ b/test/app-init.bats @@ -25,11 +25,11 @@ load utils app init -d my-app maven -r "file://$BATS_TMPDIR/repo" org.example:app-a:1.0-SNAPSHOT; echo_lines eq '$status' 0 eq '${lines[0]}' "Resolving Maven version 1.0-SNAPSHOT..." - match '${lines[1]}' "Resolved version to 1.0-.*" - match '${lines[2]}' "Downloading org.example:app-a:1.0-.*" + match '${lines[1]}' "Resolved version to 1.0-*" + match '${lines[2]}' "Downloading org.example:app-a:1.0-*" eq '${lines[3]}' "Unpacking..." match '${lines[4]}' "Importing config from versions/1.0-*" - match '${lines[5]}' "Creating current symlink for version 1.0-.*" + match '${lines[5]}' "Creating current symlink for version 1.0-*" eq '${lines[6]}' "Post install" eq '${#lines[*]}' 7 @@ -37,3 +37,22 @@ load utils # Created by post-install is_directory "my-app/logs" } + +@test "Install release artifact" { + mkzip app-a + install_artifact 1.0 + + app init -d my-app maven -r "file://$BATS_TMPDIR/repo" org.example:app-a:1.0; echo_lines + eq '$status' 0 + match '${lines[0]}' "Resolved version to 1.0" + match '${lines[1]}' "Downloading org.example:app-a:1.0-*" + eq '${lines[2]}' "Unpacking..." + match '${lines[3]}' "Importing config from versions/1.0-*" + match '${lines[4]}' "Creating current symlink for version 1.0-*" + eq '${lines[5]}' "Post install" + eq '${#lines[*]}' 6 + + is_directory "my-app/.app" + # Created by post-install + is_directory "my-app/logs" +} diff --git a/test/data/app-cat-conf/config-4 b/test/data/app-cat-conf/config-4 new file mode 100644 index 0000000..8b3d4e9 --- /dev/null +++ b/test/data/app-cat-conf/config-4 @@ -0,0 +1 @@ +foo.bar=foo diff --git a/test/data/app-cat-conf/home/.appconfig b/test/data/app-cat-conf/home/.appconfig new file mode 100644 index 0000000..a505098 --- /dev/null +++ b/test/data/app-cat-conf/home/.appconfig @@ -0,0 +1,2 @@ +foo.bar=1 +foo.foo=2 diff --git a/test/data/app-cat-conf/my-app/.app/config b/test/data/app-cat-conf/my-app/.app/config new file mode 100644 index 0000000..e3624d5 --- /dev/null +++ b/test/data/app-cat-conf/my-app/.app/config @@ -0,0 +1,2 @@ +foo.baz=3 +foo.bar=2 diff --git a/test/utils.bash b/test/utils.bash index ad80629..26be39d 100644 --- a/test/utils.bash +++ b/test/utils.bash @@ -42,10 +42,11 @@ mkzip() { } install_artifact() { + local version=${1-1.0-SNAPSHOT} describe -Dfile=`fix_path $APPSH_HOME/test/data/app-a.zip` -DgeneratePom PATH=$ORIG_PATH mvn deploy:deploy-file -Durl=$FIXED_REPO_URL \ -Dfile=`fix_path $APPSH_HOME/test/data/app-a.zip` -DgeneratePom \ - -DgroupId=org.example -DartifactId=app-a -Dversion=1.0-SNAPSHOT -Dpackaging=zip + -DgroupId=org.example -DartifactId=app-a -Dversion=$version -Dpackaging=zip } app() { |