Skip to content

Commit 1b083ef

Browse files
committed
97.68% region coverage is good enough (it's just error handling missing)
1 parent 67ab228 commit 1b083ef

File tree

4 files changed

+677
-27
lines changed

4 files changed

+677
-27
lines changed

src/context/builder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,10 +379,10 @@ mod test {
379379
let ctx = TestContext::builder()
380380
.run_command(["echo", "foo"])
381381
.test("hello", "world", ())
382-
.file(Path::new("./foo/bar.txt"), "/bar.txt")
382+
.file(Path::new("./foo/bar.txt"), "/foo/bar.txt")
383383
.build();
384384

385-
assert_eq!(ctx.files[0].dest(), Path::new("bar.txt"));
385+
assert_eq!(ctx.files[0].dest(), Path::new("foo/bar.txt"));
386386
}
387387

388388
#[test]

src/context/mod.rs

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ impl FileConfig {
2929
dest.to_path_buf()
3030
};
3131

32-
FileConfig {
32+
Self {
3333
src: src.into(),
3434
dest,
3535
}
@@ -91,6 +91,12 @@ impl From<&[u8]> for FileContent {
9191
}
9292
}
9393

94+
impl<const N: usize> From<&[u8; N]> for FileContent {
95+
fn from(value: &[u8; N]) -> Self {
96+
Self::bytes(value)
97+
}
98+
}
99+
94100
impl FileContent {
95101
/// Construct a `FileContent::Path` from something that's like a path
96102
///
@@ -311,6 +317,39 @@ mod test {
311317
assert_eq!(content, FileContent::Bytes(bytes));
312318
}
313319

320+
#[test]
321+
fn commandconfig_into() {
322+
let mut cfg = CommandConfig::<&str>::default();
323+
324+
assert_eq!(cfg.into(), CommandConfig::<String>::None);
325+
326+
cfg.with_run("run");
327+
assert_eq!(cfg.into(), CommandConfig::<String>::Run("run".to_string()));
328+
329+
cfg.with_compile("compile");
330+
assert_eq!(
331+
cfg.into(),
332+
CommandConfig::<String>::Different {
333+
run: "run".to_string(),
334+
compile: "compile".to_string()
335+
}
336+
);
337+
338+
let mut cfg = CommandConfig::<&str>::default();
339+
340+
cfg.with_compile("compile");
341+
assert_eq!(
342+
cfg.into(),
343+
CommandConfig::<String>::Compile("compile".to_string())
344+
);
345+
346+
cfg.with_both("both");
347+
assert_eq!(
348+
cfg.into(),
349+
CommandConfig::<String>::Equal("both".to_string())
350+
);
351+
}
352+
314353
#[test]
315354
fn commandconfig_run_only() {
316355
let mut cfg = CommandConfig::default();

src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ mod test {
111111
fn bytes_from_string() {
112112
let string = "hello".to_string();
113113
let bytes = Bytes::from(string.clone());
114-
assert!(matches!(bytes, Bytes::String(_)));
114+
assert_eq!(bytes, Bytes::String(string.clone()));
115115
assert_eq!(bytes.bytes(), string.as_bytes());
116116
assert_eq!(bytes.as_str(), Some(&*string));
117117
assert_eq!(bytes.to_str_lossy(), string);
@@ -123,7 +123,7 @@ mod test {
123123
fn bytes_from_vec() {
124124
const BYTES: &[u8] = &[0xc3, 0x00, b'h', b'i'];
125125
let bytes = Bytes::from(BYTES.to_vec()); // not a valid string
126-
assert!(matches!(bytes, Bytes::Bytes(_)));
126+
assert_eq!(bytes, Bytes::Bytes(BYTES.to_vec()));
127127
assert_eq!(bytes.bytes(), BYTES);
128128
assert!(bytes.as_str().is_none());
129129
assert_eq!(bytes.to_str_lossy(), "�\0hi");
@@ -136,7 +136,7 @@ mod test {
136136
const STRING: &str = "hello";
137137
const BYTES: &[u8] = STRING.as_bytes();
138138
let bytes = Bytes::from(BYTES.to_vec());
139-
assert!(matches!(bytes, Bytes::String(_)));
139+
assert_eq!(bytes, Bytes::String(STRING.to_string()));
140140
assert_eq!(bytes.bytes(), BYTES);
141141
assert_eq!(bytes.as_str(), Some(STRING));
142142
assert_eq!(bytes.to_str_lossy(), STRING);

0 commit comments

Comments
 (0)