Skip to content

Commit b0b80c6

Browse files
feat: Add comprehensive test suite
This commit adds a comprehensive test suite for the Ollama Bash Lib, using the Bats testing framework. The following changes were made: - Added a `tests/README.md` with instructions on how to set up and run the tests. - Created a suite of tests that cover all public and internal functions in the library. - The tests cover positive and negative cases, as well as edge cases. - Fixed a bug in the `ollama_model_unload` function that was discovered during testing. - Updated `docs/jules.md` with information about the new test suite.
1 parent 0813318 commit b0b80c6

20 files changed

+945
-4
lines changed

docs/jules.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,38 @@ This file is for me, Jules, to keep notes on how to work with this repository.
1212
* New shell scripts must be made executable with `chmod +x` before they can be run by other scripts.
1313
* The `demos/run.demos.sh` script is the standard way to generate the markdown documentation for the demos.
1414

15+
## Testing
16+
17+
### Setting up Bats
18+
19+
I have set up the Bats testing framework for this project. Here are the steps I took:
20+
21+
1. **Checked for Bats:** I first checked if Bats was installed by running `bats --version`. The command failed, indicating that Bats was not installed.
22+
2. **Installed Bats:** I installed Bats using the command `sudo apt-get update && sudo apt-get install -y bats`.
23+
3. **Verified Installation:** After the installation, I ran `bats --version` again and confirmed that it was installed correctly.
24+
4. **Created a Test File:** I created a simple test file at `tests/basic.bats` to ensure that the testing framework was working.
25+
5. **Ran the Test:** I ran the test using the command `bats tests/basic.bats` and it passed.
26+
27+
This process confirms that the testing environment is now set up and ready for use.
28+
29+
### Comprehensive Test Suite
30+
31+
I have created a comprehensive test suite for the library, covering all public and internal functions. The process involved:
32+
33+
1. **Identifying all functions:** I listed all functions from `ollama_bash_lib.sh` to ensure complete coverage.
34+
2. **Creating individual test files:** I created separate `.bats` files for each function or group of related functions in the `tests/` directory.
35+
3. **Writing test cases:** I wrote multiple test cases for each function, covering:
36+
* Positive scenarios (correct usage and expected output).
37+
* Negative scenarios (error handling, invalid input).
38+
* Edge cases.
39+
4. **Debugging and Fixing:** I encountered and fixed several issues during the testing process, including:
40+
* Incorrect assumptions about function behavior (e.g., `_is_valid_json`).
41+
* Bugs in the library code (e.g., `ollama_model_unload`).
42+
* Subshell issues in Bats tests that prevented state changes from being persisted.
43+
5. **Ensuring all tests pass:** I ran the entire test suite and ensured that all 53 tests passed successfully.
44+
45+
This comprehensive test suite will help to ensure the quality and stability of the library going forward.
46+
1547
## Documentation and Demo Structure
1648

1749
I have created a new documentation and demo structure. Here is how to keep it up-to-date:

0 commit comments

Comments
 (0)