Skip to content

Commit

Permalink
Add bb task as shortcut to run tests without building the docker img
Browse files Browse the repository at this point in the history
  • Loading branch information
ccfontes committed Dec 18, 2023
1 parent 25149a5 commit 880c676
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/faas_fn_build_invoke.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ jobs:
docker logs bb-routes
exit 9
fi
pushd examples/http/bb-routes
bb test
popd
(docker stop bb-routes-bell || exit 0)
(docker rm bb-routes-bell || exit 0)
Expand Down
10 changes: 9 additions & 1 deletion README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,14 @@ The `event` is extracted from the HTTP payload body, and the function return is

=== Function tests

Tests for your Function run when you build the Function image (`faas-cli build`).

To run tests without building the Function's docker image, use the following command in the root directory of your Function:
[source, bash]
----
bb test
----

To test the code of a Function, a `test` directory in the Function's top-level directory is provided, containing:

* `run_tests.clj`, with the namespace that will be used to run the tests. You can use any test library and test runner you like.
Expand All @@ -131,7 +139,7 @@ my-function:

If you don't plan on testing, you can remove the `test` directory altogether.

Existing test files are removed from the final Docker image used to run the Function in OpenFaaS.
Existing test files are removed from the final Docker image used to deploy the Function to OpenFaaS.

=== Spin up a REPL

Expand Down
3 changes: 2 additions & 1 deletion examples/http/bb-hello/bb.edn
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
{:paths ["."]}
{:paths ["."]
:tasks {test test.run-tests/-main}}
3 changes: 2 additions & 1 deletion examples/http/bb-routes-bell/bb.edn
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
{:paths ["."]
:deps {net.tessellator/bell {:mvn/version "0.2.0"}}}
:deps {net.tessellator/bell {:mvn/version "0.2.0"}}
:tasks {test test.run-tests/-main}}
3 changes: 2 additions & 1 deletion examples/http/bb-routes/bb.edn
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
{:paths ["."]}
{:paths ["."]
:tasks {test test.run-tests/-main}}
3 changes: 2 additions & 1 deletion template/bb/function/bb.edn
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
{:paths ["."]
:deps {}}
:deps {}
:tasks {test test.run-tests/-main}}

0 comments on commit 880c676

Please sign in to comment.