From d4204d63357b893da3093ba690960997b1ec14d1 Mon Sep 17 00:00:00 2001 From: Minigrim0 Date: Fri, 16 Jun 2023 16:45:57 +0200 Subject: [PATCH] [Upd] no limit on task results + better test env --- .github/workflows/rust_test.yml | 2 +- README.md | 8 +++++++- src/database.rs | 2 -- test.sh | 4 ++++ 4 files changed, 12 insertions(+), 4 deletions(-) create mode 100755 test.sh diff --git a/.github/workflows/rust_test.yml b/.github/workflows/rust_test.yml index 0c8f022..dd325c9 100644 --- a/.github/workflows/rust_test.yml +++ b/.github/workflows/rust_test.yml @@ -35,4 +35,4 @@ jobs: run: source "$HOME/.cargo/env" && cargo build --verbose - name: Run tests - run: source "$HOME/.cargo/env" && cargo test --verbose -- --test-threads=1 + run: source "$HOME/.cargo/env" && ./test.sh diff --git a/README.md b/README.md index f7dda6f..179bb9a 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ This project is a cli project that allows users to create a task list and add ta Some tasks may have deadlines and the user can set the deadline for the task. The user can also view the tasks that are overdue. -## Commands +## ⌨️ Commands The following commands are available to the user: ``` todo -a [-D '' -e ''] # Adds a task to the list @@ -14,3 +14,9 @@ todo -l [--overdue] # Views the tasks in the list todo -c # Marks a task as done todo -d # Deletes a task from the list ``` + +## 🧪 Testing +To run tests, simply run the `test.sh` script from the root folder. +It will create a testing database (to avoid unintended modifications in your main one) and delete it once the tests are done. + +It will also make sure the tests are not run in parallel as sqlite does not support concurrency. diff --git a/src/database.rs b/src/database.rs index 7f952ef..cf52e15 100644 --- a/src/database.rs +++ b/src/database.rs @@ -37,13 +37,11 @@ pub fn read_tasks(overdue: bool) -> Vec { if overdue { results = tasks .filter(status.eq(true)) - .limit(5) .select(Task::as_select()) .load(connection) .expect("Error loading tasks"); } else { results = tasks - .limit(5) .select(Task::as_select()) .load(connection) .expect("Error loading tasks"); diff --git a/test.sh b/test.sh new file mode 100755 index 0000000..7ed2f47 --- /dev/null +++ b/test.sh @@ -0,0 +1,4 @@ +export DATABASE_URL=sqlite://todo_test.sqlite3 +diesel migration run +cargo test --verbose -- --test-threads=1 +rm todo_test.sqlite3