Skip to content

Commit e1c3375

Browse files
fix failing test
1 parent 1e2fa5d commit e1c3375

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

src/tests/check_docs_exist.bats

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,28 @@
1-
#! /bin/bash
1+
#!/bin/bash
22

3+
# Assign the value to the variable "TEST_DIR"
4+
# shellcheck disable=SC2155
5+
export TEST_DIR="$(pwd)/test_docs_dir_with_files"
36

4-
5-
declare -x TEST_DIR=""
6-
TEST_DIR="$(pwd)/test_docs_dir_with_files"
7-
8-
create_test_dir(){
9-
mkdir "$TEST_DIR"
7+
create_test_dir() {
8+
mkdir -p "$TEST_DIR"
109
}
1110

12-
create_test_files(){
13-
create_test_dir;
14-
touch "$TEST_DIR/file1.txt"
15-
touch "$TEST_DIR/file2.txt"
11+
create_test_files() {
12+
create_test_dir
13+
touch "$TEST_DIR/file1.txt"
14+
touch "$TEST_DIR/file2.txt"
1615
}
1716

18-
erase_test_files(){
19-
rm -rf "$TEST_DIR"
17+
erase_test_files() {
18+
rm -rf "$TEST_DIR"
2019
}
2120

2221
# Source the script to get the CheckDocsExist function
2322
source ./src/scripts/check_docs_exist.sh
2423

2524
@test "It checks if documents exist in source directory and finds files" {
26-
create_test_files;
25+
create_test_files
2726

2827
export FULL_SOURCE_DOCS_PATH="$TEST_DIR"
2928

@@ -34,11 +33,11 @@ source ./src/scripts/check_docs_exist.sh
3433
[[ "$output" == "Checking if documents exist in the source directory." ]]
3534
[[ "$status" -eq 0 ]]
3635

37-
erase_test_files;
36+
erase_test_files
3837
}
3938

4039
@test "It checks if documents exist in source directory and finds no files" {
41-
create_test_dir;
40+
create_test_dir
4241

4342
ls() { :; } # Mock ls to simulate an empty directory
4443

@@ -51,7 +50,7 @@ source ./src/scripts/check_docs_exist.sh
5150
[[ "$output" =~ "No files found" ]]
5251
[[ "$status" -eq 1 ]]
5352

54-
erase_test_files;
53+
erase_test_files
5554
}
5655

5756
@test "It checks if documents exist in a non-existent source directory" {

0 commit comments

Comments
 (0)