Skip to content

Commit

Permalink
feat: add extra test
Browse files Browse the repository at this point in the history
  • Loading branch information
zeldan committed Nov 5, 2024
1 parent fbd0cdc commit 600c068
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@ jobs:
runs-on: ubuntu-latest

steps:

- uses: actions/checkout@v4

- name: Version
run: cargo --version --verbose

- name: Build
run: cargo build --verbose

- name: Run tests
run: cargo test --verbose
15 changes: 14 additions & 1 deletion src/util/date.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ pub fn get_date_from_string(tz: Tz, date: &String) -> DateTime<Utc> {

#[cfg(test)]
mod tests {
use chrono::TimeZone;
use chrono::{TimeZone, Weekday};

use super::*;

Expand Down Expand Up @@ -167,4 +167,17 @@ mod tests {
assert_eq!(actual_date, expected_date);
Ok(())
}

#[test]
fn test_get_start_of_the_week() -> Result<(), String> {
let now = Local::now();

let start_of_the_week = get_start_of_the_week();

let days_difference = now.signed_duration_since(start_of_the_week).num_days();
assert!(start_of_the_week <= now);
assert!(days_difference >= 0 && days_difference <= 6);
assert_eq!(start_of_the_week.weekday(), Weekday::Mon);
Ok(())
}
}

0 comments on commit 600c068

Please sign in to comment.