diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 61b4792..50f166f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -42,9 +42,27 @@ jobs: sudo ./bats-core/install.sh /usr/local fi - # Verify BATS helpers are available + # Install BATS helpers + mkdir -p tests/test_helper + + # Install bats-support + if [ ! -d "tests/test_helper/bats-support" ]; then + git clone --depth 1 https://github.com/bats-core/bats-support.git tests/test_helper/bats-support + fi + + # Install bats-assert + if [ ! -d "tests/test_helper/bats-assert" ]; then + git clone --depth 1 https://github.com/bats-core/bats-assert.git tests/test_helper/bats-assert + fi + + # Install bats-file + if [ ! -d "tests/test_helper/bats-file" ]; then + git clone --depth 1 https://github.com/bats-core/bats-file.git tests/test_helper/bats-file + fi + + # Verify BATS helpers were installed if [ ! -d "tests/test_helper/bats-support" ] || [ ! -d "tests/test_helper/bats-assert" ] || [ ! -d "tests/test_helper/bats-file" ]; then - echo "Error: BATS helper libraries not found in test_helper directory" + echo "Error: Failed to install BATS helper libraries" ls -la tests/test_helper/ exit 1 fi diff --git a/tests/parser.bats b/tests/parser.bats index 267a685..5654bfd 100755 --- a/tests/parser.bats +++ b/tests/parser.bats @@ -1,9 +1,7 @@ #!/usr/bin/env bats -# Load BATS helper libraries -load 'test_helper/bats-support/load' -load 'test_helper/bats-assert/load' -load 'test_helper/bats-file/load' +# Load test helper +load 'test_helper' # Simple test for parse_volume function @test "parse_volume should parse volume string correctly" { diff --git a/tests/test_helper.bash b/tests/test_helper.bash new file mode 100644 index 0000000..0f3226b --- /dev/null +++ b/tests/test_helper.bash @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +# Set the path to the BATS helpers +export BATS_HELPER_PATH="${BATS_TEST_DIRNAME}/test_helper" + +# Load BATS helper libraries +load "${BATS_HELPER_PATH}/bats-support/load.bash" +load "${BATS_HELPER_PATH}/bats-assert/load.bash" +load "${BATS_HELPER_PATH}/bats-file/load.bash" + +# Setup function that runs before each test +setup() { + # Add any test setup code here + : +} + +# Teardown function that runs after each test +teardown() { + # Add any test teardown code here + : +}