From 18dc6e9434817671c95b76f8d29accbda3a6a51c Mon Sep 17 00:00:00 2001 From: decentral1se Date: Tue, 5 Sep 2023 11:12:04 +0200 Subject: [PATCH] feat: support abra testing mode --- pkg/config/env.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/pkg/config/env.go b/pkg/config/env.go index e799f58b..c0358dbb 100644 --- a/pkg/config/env.go +++ b/pkg/config/env.go @@ -14,7 +14,17 @@ import ( "github.com/sirupsen/logrus" ) -var ABRA_DIR = os.ExpandEnv("$HOME/.abra") +// getBaseDir retrieves the Abra base directory. +func getBaseDir() string { + home := os.ExpandEnv("$HOME/.abra") + if _, exists := os.LookupEnv("ABRA_TEST"); exists { + home = os.ExpandEnv("$HOME/.abra_test") + logrus.Debugf("running under test mode as requested (ABRA_TEST)") + } + return home +} + +var ABRA_DIR = getBaseDir() var SERVERS_DIR = path.Join(ABRA_DIR, "servers") var RECIPES_DIR = path.Join(ABRA_DIR, "recipes") var VENDOR_DIR = path.Join(ABRA_DIR, "vendor")