• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

MitMaro / git-interactive-rebase-tool / 6883077488

15 Nov 2023 09:23PM UTC coverage: 93.248% (-0.4%) from 93.64%
6883077488

Pull #873

github

web-flow
Merge 0ab516642 into d7655157f
Pull Request #873: When editing in the middle of a rebase, dont clear on quit

45 of 72 new or added lines in 14 files covered. (62.5%)

1 existing line in 1 file now uncovered.

4792 of 5139 relevant lines covered (93.25%)

3.67 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

83.33
/src/todo_file/src/errors/io.rs
1
use std::{io, path::PathBuf};
2

3
use thiserror::Error;
4

5
use crate::errors::ParseError;
6

7
/// The cause of a `FileRead` error
8
#[derive(Error, Debug)]
9
#[non_exhaustive]
10
#[allow(variant_size_differences)]
11
pub enum FileReadErrorCause {
12
        /// Caused by an io error
13
        #[error(transparent)]
14
        IoError(#[from] io::Error),
15
        /// Caused by a parse error
16
        #[error(transparent)]
17
        ParseError(#[from] ParseError),
18
        /// Caused by the file path returning None for parent()
19
        #[error("NoParentDir")]
20
        NoParentDir(),
21
}
22

23
impl PartialEq for FileReadErrorCause {
24
        #[inline]
25
        #[allow(clippy::pattern_type_mismatch)]
26
        fn eq(&self, other: &Self) -> bool {
2✔
27
                match (self, other) {
1✔
28
                        (Self::IoError(self_err), Self::IoError(other_err)) => self_err.kind() == other_err.kind(),
1✔
29
                        (Self::ParseError(self_err), Self::ParseError(other_err)) => self_err == other_err,
1✔
NEW
30
                        (Self::NoParentDir(), Self::NoParentDir()) => true,
×
31
                        _ => false,
1✔
32
                }
33
        }
34
}
35

36
/// IO baser errors
37
#[derive(Error, Debug, PartialEq)]
38
#[non_exhaustive]
39
pub enum IoError {
40
        /// The file could not be read
41
        #[error("Unable to read file `{file}`")]
42
        FileRead {
43
                /// The file path that failed to read
44
                file: PathBuf,
45
                /// The reason for the read error
46
                cause: FileReadErrorCause,
47
        },
48
}
49

50
#[cfg(test)]
51
mod test {
52
        use super::*;
53

54
        #[test]
55
        fn partial_eq_file_read_error_cause_different_cause() {
56
                assert_ne!(
57
                        FileReadErrorCause::IoError(io::Error::from(io::ErrorKind::Other)),
58
                        FileReadErrorCause::ParseError(ParseError::InvalidAction(String::from("action")))
59
                );
60
        }
61

62
        #[test]
63
        fn partial_eq_file_read_error_cause_io_error_same_kind() {
64
                assert_eq!(
65
                        FileReadErrorCause::IoError(io::Error::from(io::ErrorKind::Other)),
66
                        FileReadErrorCause::IoError(io::Error::from(io::ErrorKind::Other))
67
                );
68
        }
69

70
        #[test]
71
        fn partial_eq_file_read_error_cause_io_error_different_kind() {
72
                assert_ne!(
73
                        FileReadErrorCause::IoError(io::Error::from(io::ErrorKind::Other)),
74
                        FileReadErrorCause::IoError(io::Error::from(io::ErrorKind::NotFound))
75
                );
76
        }
77

78
        #[test]
79
        fn partial_eq_file_read_error_cause_different_parse_error() {
80
                assert_ne!(
81
                        FileReadErrorCause::ParseError(ParseError::InvalidAction(String::from("action"))),
82
                        FileReadErrorCause::ParseError(ParseError::InvalidLine(String::from("line"))),
83
                );
84
        }
85

86
        #[test]
87
        fn partial_eq_file_read_error_cause_same_parse_error() {
88
                assert_eq!(
89
                        FileReadErrorCause::ParseError(ParseError::InvalidAction(String::from("action"))),
90
                        FileReadErrorCause::ParseError(ParseError::InvalidAction(String::from("action"))),
91
                );
92
        }
93
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc