-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tests: Remove file I/O from all tests that don't need it #7189
Comments
Generally yes, the majority of the unittests should focus on primarily exercising the edge cases of the command of interest. |
Also, some of these tests have been around longer than Nuon has been around. |
I think it would be good to clean this up where file access is unnecessary, it would simplify our tests. That said, I don’t think we’ll see any meaningful improvements in test execution time. |
I'd like to work on this particular issue |
@cosineblast go for it. i've assigned it to you. |
Is it ok to use #[test]
fn discards_rows_where_given_column_is_empty() {
let sample_json = r#"
{
"amigos": [
{"name": "Yehuda", "rusty_luck": 1},
{"name": "JT", "rusty_luck": 1},
{"name": "Andres", "rusty_luck": 1},
{"name":"GorbyPuff"}
]
}
"#;
let actual = nu!(pipeline(&format!(
"
'{}' | from json
| get amigos
| compact rusty_luck
| length
",
sample_json
)));
assert_eq!(actual.out, "3");
} |
I think generally, having simpler tests that are focussed on just the properties under test is preferrable... But nushell/crates/nu-command/src/formats/from/json.rs Lines 79 to 80 in f9c1a32
So if there is not a specific prior failure mentioned or it makes sense from the context I think this can be turned into a direct literal. |
# Description This PR implements modifications to command tests that write unnecessary json and csv to disk then load it with open, by using nuon literals instead. - Fixes #7189 # User-Facing Changes None # Tests + Formatting This only affects existing tests, which still pass.
# Description This PR implements modifications to command tests that write unnecessary json and csv to disk then load it with open, by using nuon literals instead. - Fixes nushell#7189 # User-Facing Changes None # Tests + Formatting This only affects existing tests, which still pass.
# Description This PR implements modifications to command tests that write unnecessary json and csv to disk then load it with open, by using nuon literals instead. - Fixes nushell#7189 # User-Facing Changes None # Tests + Formatting This only affects existing tests, which still pass.
Related problem
An alarming amount of tests in Nu-command resemble the following:
All I have to say is: why is file I/O (and CSV parsing) even part of this test?! The test is whether the
uniq
command works. Just write the input data in Nuon! Addingopen
and an entire file playground setup just makes the test slower and more difficult to read.Describe the solution you'd like
Command tests should incisively probe the output of commands using the minimum necessary input to demonstrate whatever behaviour is being tested. Any command that doesn't involve file I/O shouldn't have it included in the test.
Describe alternatives you've considered
No response
Additional context and details
No response
The text was updated successfully, but these errors were encountered: