Skip to content

Commit

Permalink
Added unit tests, improved position unit test and added contributing …
Browse files Browse the repository at this point in the history
…info to README.
  • Loading branch information
RRArny committed Nov 2, 2024
1 parent b0a65bd commit b0bd554
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 13 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,11 @@ For wxfetch to work you will need a free account on https://avwx.rest/. Once you
Wxfetch is written in Rust. In order to build it, run `cargo build` for a debug build, for a production build run `cargo build --release`. This will generate a binary file within the `target` directory in the `debug` and `release` subdirectories respectively.

For working on Wxfetch this repository includes a bacon configuration. Run `bacon` to have a variety of jobs at your disposal. `bacon clippy` (or using the 'c' key) will run the clippy linter at a pedantic level. `bacon test` (or 't') will run the unit tests. `bacon tarpaulin` (or 'alt-t') will calculate the code coverage using the `tarpaulin` plugin. You can install bacon using `cargo install bacon`.

# Contributing

This project is open source. If you would like to contribute, just fork the project, make your changes and create a pull request with a short description. I will only accept pull requests that satisfy the following criteria:
- all unit tests are passing,
- code coverage is above 50%,
- all pedantic clippy hints that still occur are explained with a comment (if they are impossible or impractical to fix, I will also be pedantic with this!),
- I deem the contribution worthwhile.
3 changes: 2 additions & 1 deletion bacon.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ command = [
need_stdout = false

[jobs.tarpaulin]
command = ["cargo", "tarpaulin", "--color", "always"]
command = ["cargo", "tarpaulin", "--color", "always",
"--", "--color", "always"]
need_stdout = true

[jobs.clippy-all]
Expand Down
7 changes: 7 additions & 0 deletions src/metar/clouds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ impl Display for Clouds {
mod tests {
use std::str::FromStr;

use anyhow::{Error, Result};
use serde_json::Value;

use crate::metar::WxField;
Expand Down Expand Up @@ -134,6 +135,12 @@ mod tests {
assert_eq!(Some(expected), actual);
}

#[test]
fn test_clouds_from_str_err() {
let actual = clouds_from_str("OCC33");
assert!(actual.is_none());
}

#[test]
fn test_get_clouds() {
let json: Value = Value::from_str(
Expand Down
13 changes: 1 addition & 12 deletions src/position.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,6 @@ mod test {
let latlon = LatLong(51.4, 8.5);
let expected = "51.4,8.5";
let actual = latlon.to_string();
// let actual = format!("{latlon}");
assert!(expected == actual);
assert_eq!(expected, actual);
}

// #[test]
// async fn test_locstr_icao() {
// let icao = Position::Airfield("EDDF".to_string());
// let expected = "EDDF";
// let actual = icao.get_location_str().await;
// assert!(expected == actual);
// }
// #[test]
// fn test_locstr_latlon() {}
}

0 comments on commit b0bd554

Please sign in to comment.