#!/usr/bin/env bats # vim: set filetype=sh: load utils setup_inner() { mkdir .app; touch .app/config export APPSH_DEFAULT_CONFIG=/dev/null } @test "./app conf - happy day" { app conf; echo_lines 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; echo_lines eq '$status' 0 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 eq '${lines[0]}' "bar" eq '${#lines[*]}' 1 app conf delete g.foo; echo_lines eq '$status' 0 app conf; echo_lines eq '$status' 0 eq '${lines[0]}' "app.bin bin/app-a " eq '${#lines[*]}' 1 } @test "./app conf - defaults to 'list'" { echo "app.bin=bin/app-a" > .app/config app conf; echo_lines eq '$status' 0 eq '${#lines[*]}' 1 eq '${lines[0]}' "app.bin bin/app-a " } @test "./app conf wat" { app conf wat; echo_lines eq '$status' 1 eq '${lines[0]}' "Error: Unknown command: wat" } @test "./app conf list" { echo "app.bin=bin/app-a" > .app/config app conf; echo_lines eq '$status' 0 eq '${#lines[*]}' 1 eq '${lines[0]}' "app.bin bin/app-a " app conf list; echo_lines eq '$status' 0 eq '${#lines[*]}' 1 eq '${lines[0]}' "app.bin bin/app-a " app conf list foo; echo_lines 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 set" { echo "app.bin=bin/app-a" > .app/config app conf set group; echo_lines eq '$status' 1 app conf set group.foo; echo_lines eq '$status' 1 app conf set group.foo bar; echo_lines eq '$status' 0 eq '${#lines[*]}' 0 app conf; echo_lines eq '$status' 0 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 app conf list; echo_lines eq '$status' 0 eq '${lines[0]}' "foo.bar awesome " }