diff --git a/README.md b/README.md index e120f82..a1323a8 100644 --- a/README.md +++ b/README.md @@ -60,3 +60,5 @@ For wxfetch to work you will need a free account on https://avwx.rest/. Once you # Building from source 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`. diff --git a/bacon.toml b/bacon.toml index c6aed31..21a3578 100644 --- a/bacon.toml +++ b/bacon.toml @@ -5,7 +5,7 @@ # You can also check bacon's own bacon.toml file # as an example: https://github.com/Canop/bacon/blob/main/bacon.toml -default_job = "check" +default_job = "clippy" [jobs.check] command = ["cargo", "check", "--color", "always"] @@ -24,6 +24,10 @@ command = [ ] need_stdout = false +[jobs.tarpaulin] +command = ["cargo", "tarpaulin", "--color", "always"] +need_stdout = true + [jobs.clippy-all] command = [ "cargo", "clippy", @@ -87,3 +91,4 @@ allow_warnings = true [keybindings] # alt-m = "job:my-job" c = "job:clippy" # comment this to have 'c' run clippy on only the default target +alt-t = "job:tarpaulin" diff --git a/src/position.rs b/src/position.rs index f185554..1e6e27c 100644 --- a/src/position.rs +++ b/src/position.rs @@ -56,3 +56,27 @@ async fn get_geoip() -> Option { Some(LatLong(lat, long)) } + +#[cfg(test)] +mod test { + use super::*; + + #[test] + fn test_display_latlong() { + 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); + } + + // #[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() {} +}