-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from soma-smart/random_integer_provider
Create random integer provider
- Loading branch information
Showing
10 changed files
with
288 additions
and
52 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,26 @@ | ||
[package] | ||
name = "fakelake" | ||
version = "1.0.0" | ||
version = "1.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
arrow-array = "49.0.0" | ||
arrow-schema = "49.0.0" | ||
arrow-array = "50.0.0" | ||
arrow-schema = "50.0.0" | ||
chrono = "0.4.31" | ||
clap = { version = "4.4.10", features = ["derive"] } | ||
env_logger = "0.10" | ||
fastrand = "2.0.1" | ||
log = "0.4" | ||
once_cell = "1.8" | ||
parquet = "49.0.0" | ||
parquet = "50.0.0" | ||
rayon = "1.8.0" | ||
yaml-rust = "0.4" | ||
|
||
[dev-dependencies] | ||
assert_cmd = "2.0" | ||
cargo-tarpaulin = "0.27.2" | ||
cargo-tarpaulin = "0.27.3" | ||
mockall = "0.12.1" | ||
predicates = "2.1" | ||
regex = "1.5" | ||
regex = "1.5" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
pub mod builder; | ||
|
||
pub mod date; | ||
pub mod number; | ||
pub mod string; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
use crate::errors::FakeLakeError; | ||
use crate::providers::provider::Provider; | ||
|
||
use super::i32::I32Provider; | ||
|
||
use yaml_rust::Yaml; | ||
|
||
pub fn get_corresponding_provider( | ||
mut provider_split: std::str::Split<'_, char>, | ||
column: &Yaml, | ||
) -> Result<Box<dyn Provider>, FakeLakeError> { | ||
match provider_split.next() { | ||
Some("i32") => Ok(Box::new(I32Provider::new_from_yaml(column))), | ||
_ => Err(FakeLakeError::BadYAMLFormat("".to_string())), | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::get_corresponding_provider; | ||
|
||
use yaml_rust::YamlLoader; | ||
|
||
#[test] | ||
fn given_i32_should_return_provider() { | ||
let provider_name = "i32"; | ||
let yaml_str = format!("name: random_int{}provider: {}", '\n', provider_name); | ||
let column = &YamlLoader::load_from_str(yaml_str.as_str()).unwrap()[0]; | ||
|
||
let provider_split = provider_name.split('.'); | ||
match get_corresponding_provider(provider_split, column) { | ||
Ok(_) => (), | ||
_ => panic!(), | ||
} | ||
} | ||
|
||
#[test] | ||
fn given_wrong_provider_should_return_error() { | ||
let provider_name = "not_a_provider"; | ||
let yaml_str = format!("name: not{}provider: {}", '\n', provider_name); | ||
let column = &YamlLoader::load_from_str(yaml_str.as_str()).unwrap()[0]; | ||
|
||
let provider_split = provider_name.split('.'); | ||
match get_corresponding_provider(provider_split, column) { | ||
Err(_) => (), | ||
_ => panic!(), | ||
} | ||
} | ||
} |
Oops, something went wrong.