Skip to content

Commit

Permalink
[Upd] no limit on task results + better test env
Browse files Browse the repository at this point in the history
  • Loading branch information
Minigrim0 committed Jun 16, 2023
1 parent 12bf591 commit d4204d6
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/rust_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,17 @@ 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 <task> [-D '<task_description>' -e '<due_date>'] # Adds a task to the list
todo -l [--overdue] # Views the tasks in the list
todo -c <task_id> # Marks a task as done
todo -d <task_id> # 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.
2 changes: 0 additions & 2 deletions src/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,11 @@ pub fn read_tasks(overdue: bool) -> Vec<Task> {
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");
Expand Down
4 changes: 4 additions & 0 deletions test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export DATABASE_URL=sqlite://todo_test.sqlite3
diesel migration run
cargo test --verbose -- --test-threads=1
rm todo_test.sqlite3

0 comments on commit d4204d6

Please sign in to comment.