mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-22 11:13:09 +02:00
Switch to pretty_assertions
This commit is contained in:
parent
267288c9e6
commit
a143660124
47 changed files with 130 additions and 17 deletions
|
@ -43,6 +43,7 @@ assert_cmd = "^1.0.3"
|
|||
predicates = "^1.0.7"
|
||||
tempfile = "3"
|
||||
rstest = "0.10"
|
||||
pretty_assertions = "1"
|
||||
|
||||
[features]
|
||||
usage-docs = [ "mdbook", "serde_json" ]
|
||||
|
|
|
@ -43,6 +43,7 @@ where
|
|||
mod test {
|
||||
use super::super::*;
|
||||
use super::*;
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
#[test]
|
||||
fn test_arg_matching() {
|
||||
|
|
|
@ -51,6 +51,7 @@ pub(crate) fn wait_colon(input: &str) -> IResult<&str, Option<DateTime<Utc>>> {
|
|||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
#[test]
|
||||
fn test_colon_prefix() {
|
||||
|
|
|
@ -75,6 +75,7 @@ pub(crate) fn id_list(input: &str) -> IResult<&str, Vec<TaskId>> {
|
|||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
#[test]
|
||||
fn test_id_list_single() {
|
||||
|
|
|
@ -20,6 +20,7 @@ pub(crate) fn literal(literal: &'static str) -> impl Fn(&str) -> IResult<&str, &
|
|||
mod test {
|
||||
use super::super::*;
|
||||
use super::*;
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
#[test]
|
||||
fn test_arg_matching() {
|
||||
|
|
|
@ -15,6 +15,7 @@ pub(crate) fn minus_tag(input: &str) -> IResult<&str, Tag> {
|
|||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
#[test]
|
||||
fn test_plus_tag() {
|
||||
|
|
|
@ -160,12 +160,24 @@ fn named_date<Tz: TimeZone>(
|
|||
"today" => Ok((remaining, local_today)),
|
||||
"tomorrow" => Ok((remaining, local_today + Duration::days(1))),
|
||||
// TODO: lots more!
|
||||
"eod" => Ok((remaining,local_today + Duration::days(1))),
|
||||
"sod" => Ok((remaining,local_today)),
|
||||
"eow" => Ok((remaining,local_today + Duration::days((6-day_index).into()))),
|
||||
"eoww" => Ok((remaining,local_today + Duration::days((5-day_index).into()))),
|
||||
"sow" => Ok((remaining,local_today + Duration::days((6-day_index).into()))),
|
||||
"soww" => Ok((remaining,local_today + Duration::days((7-day_index).into()))),
|
||||
"eod" => Ok((remaining, local_today + Duration::days(1))),
|
||||
"sod" => Ok((remaining, local_today)),
|
||||
"eow" => Ok((
|
||||
remaining,
|
||||
local_today + Duration::days((6 - day_index).into()),
|
||||
)),
|
||||
"eoww" => Ok((
|
||||
remaining,
|
||||
local_today + Duration::days((5 - day_index).into()),
|
||||
)),
|
||||
"sow" => Ok((
|
||||
remaining,
|
||||
local_today + Duration::days((6 - day_index).into()),
|
||||
)),
|
||||
"soww" => Ok((
|
||||
remaining,
|
||||
local_today + Duration::days((7 - day_index).into()),
|
||||
)),
|
||||
_ => Err(Err::Error(Error::new(input, ErrorKind::Tag))),
|
||||
}
|
||||
.map(|(rem, dt)| (rem, dt.and_hms(0, 0, 0).with_timezone(&Utc)))
|
||||
|
@ -227,6 +239,7 @@ pub(crate) fn timestamp<Tz: TimeZone + Copy>(
|
|||
mod test {
|
||||
use super::*;
|
||||
use crate::argparse::NOW;
|
||||
use pretty_assertions::assert_eq;
|
||||
use rstest::rstest;
|
||||
|
||||
const M: i64 = 60;
|
||||
|
@ -308,12 +321,12 @@ mod test {
|
|||
#[case::today_from_evening(ldt(2021, 3, 1, 21, 30, 30), "today", ld(2021, 3, 1))]
|
||||
#[case::tomorrow(ld(2021, 3, 1), "tomorrow", ld(2021, 3, 2))]
|
||||
#[case::tomorow_from_evening(ldt(2021, 3, 1, 21, 30, 30), "tomorrow", ld(2021, 3, 2))]
|
||||
#[case::end_of_week(ld(2021,8,25,), "eow", ld(2021,8,29))]
|
||||
#[case::end_of_work_week(ld(2021,8,25), "eoww", ld(2021,8,28))]
|
||||
#[case::start_of_week(ld(2021,8,25), "sow", ld(2021,8,29))]
|
||||
#[case::start_of_work_week(ld(2021,8,25), "soww", ld(2021,8,30))]
|
||||
#[case::end_of_today(ld(2021,8,25), "eod", ld(2021,8,26))]
|
||||
#[case::start_of_today(ld(2021,8,25), "sod", ld(2021,8,25))]
|
||||
#[case::end_of_week(ld(2021, 8, 25,), "eow", ld(2021, 8, 29))]
|
||||
#[case::end_of_work_week(ld(2021, 8, 25), "eoww", ld(2021, 8, 28))]
|
||||
#[case::start_of_week(ld(2021, 8, 25), "sow", ld(2021, 8, 29))]
|
||||
#[case::start_of_work_week(ld(2021, 8, 25), "soww", ld(2021, 8, 30))]
|
||||
#[case::end_of_today(ld(2021, 8, 25), "eod", ld(2021, 8, 26))]
|
||||
#[case::start_of_today(ld(2021, 8, 25), "sod", ld(2021, 8, 25))]
|
||||
fn test_local_timestamp(
|
||||
#[case] now: Box<dyn Fn(FixedOffset) -> DateTime<Utc>>,
|
||||
#[values(*IST, *UTC_FO, *HST)] tz: FixedOffset,
|
||||
|
|
|
@ -58,6 +58,7 @@ impl Command {
|
|||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
// NOTE: most testing of specific subcommands is handled in `subcommand.rs`.
|
||||
|
||||
|
|
|
@ -201,6 +201,7 @@ impl Filter {
|
|||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
#[test]
|
||||
fn test_empty_parse0() {
|
||||
|
|
|
@ -165,6 +165,7 @@ impl Modification {
|
|||
mod test {
|
||||
use super::*;
|
||||
use crate::argparse::NOW;
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
#[test]
|
||||
fn test_empty() {
|
||||
|
|
|
@ -411,6 +411,7 @@ impl Sync {
|
|||
mod test {
|
||||
use super::*;
|
||||
use crate::argparse::Condition;
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
const EMPTY: Vec<&str> = vec![];
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@ impl From<std::io::Error> for Error {
|
|||
mod test {
|
||||
use super::*;
|
||||
use anyhow::anyhow;
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
#[test]
|
||||
fn test_exit_status() {
|
||||
|
|
|
@ -20,6 +20,7 @@ pub(crate) fn execute<W: WriteColor>(
|
|||
mod test {
|
||||
use super::*;
|
||||
use crate::invocation::test::*;
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
#[test]
|
||||
fn test_add() {
|
||||
|
|
|
@ -34,6 +34,7 @@ pub(crate) fn execute<W: WriteColor>(
|
|||
mod test {
|
||||
use super::*;
|
||||
use crate::invocation::test::*;
|
||||
use pretty_assertions::assert_eq;
|
||||
use std::fs;
|
||||
use tempfile::TempDir;
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ pub(crate) fn execute<W: WriteColor>(w: &mut W, replica: &mut Replica) -> Result
|
|||
mod test {
|
||||
use super::*;
|
||||
use crate::invocation::test::*;
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
#[test]
|
||||
fn test_gc() {
|
||||
|
|
|
@ -50,6 +50,7 @@ pub(crate) fn execute<W: WriteColor>(
|
|||
mod test {
|
||||
use super::*;
|
||||
use crate::invocation::test::*;
|
||||
|
||||
use taskchampion::Status;
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -71,6 +71,7 @@ mod test {
|
|||
use crate::argparse::DescriptionMod;
|
||||
use crate::invocation::test::test_replica;
|
||||
use crate::invocation::test::*;
|
||||
use pretty_assertions::assert_eq;
|
||||
use taskchampion::Status;
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -19,6 +19,7 @@ mod test {
|
|||
use super::*;
|
||||
use crate::argparse::Filter;
|
||||
use crate::invocation::test::*;
|
||||
|
||||
use taskchampion::Status;
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -15,6 +15,7 @@ pub(crate) fn execute<W: WriteColor>(
|
|||
mod test {
|
||||
use super::*;
|
||||
use crate::invocation::test::*;
|
||||
use pretty_assertions::assert_eq;
|
||||
use tempfile::TempDir;
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -172,6 +172,7 @@ pub(super) fn filtered_tasks(
|
|||
mod test {
|
||||
use super::*;
|
||||
use crate::invocation::test::*;
|
||||
use pretty_assertions::assert_eq;
|
||||
use taskchampion::Status;
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -133,6 +133,7 @@ mod test {
|
|||
use crate::invocation::test::*;
|
||||
use crate::settings::Sort;
|
||||
use chrono::prelude::*;
|
||||
use pretty_assertions::assert_eq;
|
||||
use std::convert::TryInto;
|
||||
use taskchampion::{Status, Uuid};
|
||||
|
||||
|
|
|
@ -259,6 +259,7 @@ pub(crate) fn get_usage(u: &mut Usage) {
|
|||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
use pretty_assertions::assert_eq;
|
||||
use taskchampion::Status;
|
||||
use toml::toml;
|
||||
|
||||
|
|
|
@ -325,6 +325,7 @@ impl Default for Settings {
|
|||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
use pretty_assertions::assert_eq;
|
||||
use tempfile::TempDir;
|
||||
use toml::toml;
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ pub(super) fn table_with_keys<'a>(cfg: &'a toml::Value, keys: &[&str]) -> Result
|
|||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
use pretty_assertions::assert_eq;
|
||||
use toml::toml;
|
||||
|
||||
#[test]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue