Skip to content

Commit

Permalink
Merge pull request #234 from TypedDevs/chore/233-improve-example
Browse files Browse the repository at this point in the history
Improve tests from example dir
  • Loading branch information
Chemaclass authored Dec 6, 2023
2 parents ca59cc0 + 214797a commit c443051
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 127 deletions.
8 changes: 0 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ help:
@echo " test Run the test"
@echo " test/list List all the test under the tests directory"
@echo " test/watch Automatically run the test every second"
@echo " test/example Run test from the example directory"
@echo " env/example Makes a copy of the keys on your .env file"
@echo " pre_commit/install Installs the pre-commit hook"
@echo " pre_commit/run Function that will be called when the pre-commit runs"
Expand Down Expand Up @@ -90,10 +89,3 @@ ifndef LINTER_CHECKER
else
@ec -config .editorconfig && printf "\e[1m\e[32m%s\e[0m\n" "editorconfig-check: OK!"
endif

test/example:
@./bashunit $(EXAMPLE_TEST_SCRIPTS)

test/watch/example:
@./bashunit $(EXAMPLE_TEST_SCRIPTS)
@fswatch -m poll_monitor -or $(EXAMPLE_TEST_SCRIPTS) | xargs -n1 ./bashunit $(EXAMPLE_TEST_SCRIPTS)
4 changes: 2 additions & 2 deletions example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ An example using this **bashunit** testing library.

## Demo usage

This demo uses **bashunit** itself. There, you'll find various tests showcasing the file and different **bashunit** functionalities.
This demo uses **bashunit** itself. You will find various tests showcasing the file and different **bashunit** functionalities.

To run the tests from this example, simply execute the following command from the project root folder.
```bash
make test/example
./bashunit example
```
5 changes: 5 additions & 0 deletions example/custom_functions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

function say_hi(){
echo "Hi, $1!"
}
14 changes: 14 additions & 0 deletions example/custom_functions_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

function set_up() {
ROOT_DIR="$(dirname "${BASH_SOURCE[0]}")/.."
source "$ROOT_DIR/example/custom_functions.sh"
}

function test_say_hi_Alice() {
assert_equals "Hi, Alice!" "$(say_hi "Alice")"
}

function test_say_hi_Bob() {
assert_equals "Hi, Bob!" "$(say_hi "Bob")"
}
117 changes: 0 additions & 117 deletions example/logic_test.sh

This file was deleted.

File renamed without changes.
14 changes: 14 additions & 0 deletions example/script_logic_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

function set_up() {
ROOT_DIR="$(dirname "${BASH_SOURCE[0]}")/.."
SCRIPT="$ROOT_DIR/example/script_logic.sh"
}

function test_script_123() {
assert_equals "expected 123" "$($SCRIPT "123")"
}

function test_script_456() {
assert_equals "expected 456" "$($SCRIPT "456")"
}

0 comments on commit c443051

Please sign in to comment.