-
-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathtest_helper.bash
More file actions
45 lines (36 loc) · 1.33 KB
/
test_helper.bash
File metadata and controls
45 lines (36 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# Script: test_helper.bash
# Purpose: HomeSetup test helper.
# Created: Mar 02, 2020
# Author: <B>H</B>ugo <B>S</B>aporetti <B>J</B>unior
# Mailto: taius.hhs@gmail.com
# Site: https://github.com/yorevs/homesetup
# License: Please refer to <https://opensource.org/licenses/MIT>
#
# Copyright (c) 2025, HomeSetup team
# Bats help can be found at: https://bats-core.readthedocs.io/en/stable/
export DOTFILES_DIR="${HHS_HOME}/dotfiles"
export HHS_FUNCTIONS_DIR="${HHS_HOME}/bin/hhs-functions/bash"
export HHS_APPS_DIR="${HHS_HOME}/bin/apps/bash"
export BATS_DIR="${HHS_HOME}/tests/bats"
export BATS_SUPPORT="${BATS_DIR}/bats-support/load"
export BATS_ASSERT="${BATS_DIR}/bats-assert/load"
load "${HHS_HOME}/dotfiles/bash/bash_commons.bash"
# @purpose: Load all bats libraries
load_bats_libs() {
load "${BATS_SUPPORT}"
load "${BATS_ASSERT}"
}
# @purpose: Unset all bash colors to avoid failing tests due to escape codes.
unset_colors() {
unset HHS_HIGHLIGHT_COLOR NC BLACK RED GREEN ORANGE BLUE PURPLE CYAN GRAY WHITE YELLOW VIOLET
}
# @purpose: Ensure either jq or json_pp is installed, otherwise skip the test.
ensure_json_print() {
if ! __hhs_has jq && ! __hhs_has json_pp; then
skip "Neither 'jq' and 'json_pp' are installed"
else
skip "json_print tests are disabled temporarily"
fi
}
unset_colors
bats_require_minimum_version 1.5.0