fix: overridable ABRA_DIR
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
decentral1se 2023-09-05 11:57:02 +02:00 committed by decentral1se
parent 25258d3d64
commit 58e78e4d7c
3 changed files with 26 additions and 16 deletions

View File

@ -17,9 +17,8 @@ import (
// getBaseDir retrieves the Abra base directory. // getBaseDir retrieves the Abra base directory.
func getBaseDir() string { func getBaseDir() string {
home := os.ExpandEnv("$HOME/.abra") home := os.ExpandEnv("$HOME/.abra")
if _, exists := os.LookupEnv("ABRA_TEST"); exists { if customAbraDir, exists := os.LookupEnv("ABRA_DIR"); exists && customAbraDir != "" {
home = os.ExpandEnv("$HOME/.abra_test") home = customAbraDir
logrus.Debugf("running under test mode as requested (ABRA_TEST)")
} }
return home return home
} }

View File

@ -6,22 +6,34 @@ setup() {
_setup_env _setup_env
} }
@test "ensure abra directories created" { @test "ABRA_DIR can be overriden" {
ABRA_DIR="$HOME/.abra_foo"
run $ABRA app ls run $ABRA app ls
# no servers yet, so will fail. however, it will run the required code which # no servers yet, so will fail. however, it will run the required code which
# checks if it should create these base directories and that is what we want # checks if it should create these base directories and that is what we want
assert_failure assert_failure
assert [ -d "$ABRA_TEST_DIR" ] assert [ -d "$HOME/.abra_foo" ]
assert [ -d "$ABRA_TEST_DIR/servers" ]
assert [ -d "$ABRA_TEST_DIR/recipes" ]
assert [ -d "$ABRA_TEST_DIR/backups" ]
assert [ -d "$ABRA_TEST_DIR/vendor" ]
assert [ -d "$ABRA_TEST_DIR/catalogue" ]
} }
@test "ensure catalogue recipe is a git repository" { @test "abra directories created" {
run $ABRA app ls
# no servers yet, so will fail. however, it will run the required code which
# checks if it should create these base directories and that is what we want
assert_failure
assert [ -d "$ABRA_DIR" ]
assert [ -d "$ABRA_DIR/servers" ]
assert [ -d "$ABRA_DIR/recipes" ]
assert [ -d "$ABRA_DIR/backups" ]
assert [ -d "$ABRA_DIR/vendor" ]
assert [ -d "$ABRA_DIR/catalogue" ]
}
@test "catalogue recipe is a git repository" {
run $ABRA app ls run $ABRA app ls
# no servers yet, so will fail. however, it will run the required code which # no servers yet, so will fail. however, it will run the required code which
@ -30,8 +42,8 @@ setup() {
assert_output --partial 'local recipe catalogue is missing' assert_output --partial 'local recipe catalogue is missing'
assert [ -d "$ABRA_TEST_DIR/catalogue" ] assert [ -d "$ABRA_DIR/catalogue" ]
assert [ -d "$ABRA_TEST_DIR/catalogue/.git" ] assert [ -d "$ABRA_DIR/catalogue/.git" ]
} }
teardown(){ teardown(){

View File

@ -24,13 +24,12 @@ _setup_env(){
ABRA="$ROOT/abra" ABRA="$ROOT/abra"
KADABRA="$ROOT/kadabra" KADABRA="$ROOT/kadabra"
ABRA_TEST=true ABRA_DIR="$HOME/.abra_test"
ABRA_TEST_DIR="$HOME/.abra_test"
_build_abra _build_abra
_build_kadabra _build_kadabra
} }
_default_teardown(){ _default_teardown(){
rm -rf "$ABRA_TEST_DIR" rm -rf "$ABRA_DIR"
} }