Skip to content

Commit

Permalink
fixed note edition get timestamp test, created CI
Browse files Browse the repository at this point in the history
  • Loading branch information
khan5ula committed Oct 11, 2024
1 parent 3ae4cec commit 651160c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
24 changes: 24 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Cargo Build & Test

on:
push:
pull_request:

env:
CARGO_TERM_COLOR: always

jobs:
build_and_test:
name: Noted - latest
runs-on: ubuntu-latest
strategy:
matrix:
toolchain:
- stable
- beta
- nightly
steps:
- uses: actions/checkout@v4
- run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }}
- run: cargo build --verbose
- run: cargo test --verbose
7 changes: 6 additions & 1 deletion tests/db_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ mod tests {
use std::io::BufReader;
use std::path::Path;
use std::path::PathBuf;
use std::{thread, time};
use uuid::Uuid;

struct TestDb {
Expand Down Expand Up @@ -230,6 +231,10 @@ mod tests {
.to_string()
.replace("Tomorrow", "Now");

// Wait for a second to give the timestamp chance to update
let sec = time::Duration::from_millis(1200);
thread::sleep(sec);

let edited_rows = edit_note(&conn, &id, &content).unwrap();

assert_eq!(1, edited_rows, "Editing should result in 1 updated row");
Expand All @@ -251,7 +256,7 @@ mod tests {

assert!(
third_note.get_date() < updated_third_note.get_date(),
"The date should have been changed"
"The date should have been updated"
);
}
}

0 comments on commit 651160c

Please sign in to comment.