diff options
Diffstat (limited to 'test/app-conf.bats')
-rwxr-xr-x | test/app-conf.bats | 106 |
1 files changed, 50 insertions, 56 deletions
diff --git a/test/app-conf.bats b/test/app-conf.bats index c95a133..d1a2b18 100755 --- a/test/app-conf.bats +++ b/test/app-conf.bats @@ -10,34 +10,29 @@ setup_inner() { } @test "./app conf - happy day" { - app conf; echo_lines + app conf echo "app.bin=bin/app-a" > .app/config eq '$status' 0 eq '${#lines[*]}' 0 - app conf set g.FOO bar; echo_lines - eq '$status' 0 + app conf set g.FOO bar - app conf; echo_lines - eq '$status' 0 + app conf eq '${lines[0]}' "app.bin bin/app-a " eq '${lines[1]}' "g.FOO bar " eq '${#lines[*]}' 2 - app conf get g.FOO; echo_lines - eq '$status' 0 + app conf get g.FOO eq '${lines[0]}' "bar" eq '${#lines[*]}' 1 - app conf get g.foo; echo_lines - eq '$status' 0 + app conf get g.foo eq '${#lines[*]}' 0 - app conf delete g.FOO; echo_lines - eq '$status' 0 + app conf delete g.FOO + eq '${#lines[*]}' 0 - app conf; echo_lines - eq '$status' 0 + app conf eq '${lines[0]}' "app.bin bin/app-a " eq '${#lines[*]}' 1 } @@ -45,82 +40,82 @@ setup_inner() { @test "./app conf - defaults to 'list'" { echo "app.bin=bin/app-a" > .app/config - app conf; echo_lines - eq '$status' 0 + app conf eq '${#lines[*]}' 1 eq '${lines[0]}' "app.bin bin/app-a " } @test "./app conf wat" { - app conf wat; echo_lines - eq '$status' 1 + check_status=no + app conf wat eq '${lines[0]}' "Unknown command: wat" } @test "./app conf list" { echo "app.bin=bin/app-a" > .app/config - app conf; echo_lines - eq '$status' 0 + app conf eq '${#lines[*]}' 1 eq '${lines[0]}' "app.bin bin/app-a " - app conf list; echo_lines - eq '$status' 0 + app conf list eq '${#lines[*]}' 1 eq '${lines[0]}' "app.bin bin/app-a " - app conf list foo; echo_lines + check_status=no + app conf list foo eq '$status' 1 } -#@test "./app conf list-group" { -# app conf set mygroup a 1 -# eq '$status' 0 -# app conf set mygroup b 1 -# eq '$status' 0 -# app conf set mygroup c 2 -# eq '$status' 0 -# app conf set othergroup a 1 -# eq '$status' 0 -# -# app conf list; echo_lines -# eq '$status' 0 -# app conf list-group mygroup; echo_lines -# eq '$status' 0 -# eq '${lines[0]}' "mygroup.a 1 " -# eq '${lines[1]}' "mygroup.b 1 " -# eq '${lines[2]}' "mygroup.c 2 " -# eq '${#lines[*]}' 3 -#} +@test "./app conf list - with duplicate entries" { + echo "foo.bar=awesome" > .app/config + echo "foo.bar=awesome" >> .app/config + + app conf list + eq '${lines[0]}' "foo.bar awesome " + eq '${#lines[*]}' 1 +} + +@test "./app conf list in non-app dir" { + mkdir wat + cd wat + app conf list + eq '${#lines[*]}' 0 +} @test "./app conf set" { echo "app.bin=bin/app-a" > .app/config - app conf set group; echo_lines + check_status=no + app conf set group eq '$status' 1 - app conf set group.foo; echo_lines + check_status=no + app conf set group.foo eq '$status' 1 - app conf set group.foo bar; echo_lines - eq '$status' 0 + app conf set group.foo bar eq '${#lines[*]}' 0 - app conf; echo_lines - eq '$status' 0 + app conf eq '${lines[0]}' "app.bin bin/app-a " eq '${lines[1]}' "group.foo bar " eq '${#lines[*]}' 2 } -@test "./app conf list - with duplicate entries" { - echo "foo.bar=awesome" > .app/config - echo "foo.bar=awesome" >> .app/config +@test "./app conf -l app set" { + echo > .app/config + app conf -l app set a.x 2 + app_libexec app-cat-conf + eq '${lines[0]}' "a.x=2" + eq '${#lines[*]}' 1 +} - app conf list; echo_lines - eq '$status' 0 - eq '${lines[0]}' "foo.bar awesome " +@test "./app conf -l user set" { + echo > .app/config + app conf -l user set a.x 3 + app_libexec app-cat-conf -l user + eq '${lines[0]}' "a.x=3" eq '${#lines[*]}' 1 } @@ -129,12 +124,11 @@ setup_inner() { echo "foo.baz=1" > config-b echo "foo.bar=2" >> config-b - app conf import config-b; echo_lines - eq '$status' 0 + app conf import config-b eq '${lines[0]}' "Importing config from config-b" eq '${#lines[*]}' 1 - app_libexec app-cat-conf; echo_lines + app_libexec app-cat-conf eq '${lines[0]}' "foo.bar=2" eq '${lines[1]}' "foo.baz=1" eq '${#lines[*]}' 2 |