-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(config): bump project dependencies, add tests (#56)
- [x] update cargo dependencies; - [x] add tests for configuration submodules;
- Loading branch information
Showing
8 changed files
with
146 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
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
mod artifact_configuration { | ||
use crate::data_pipeline::artifact::{configuration::ArtifactConfiguration, CONTEXTS}; | ||
|
||
#[test] | ||
fn choose_context() { | ||
let program = ArtifactConfiguration::new(CONTEXTS); | ||
let contexts = program.contexts; | ||
for (i, record) in contexts.iter().enumerate() { | ||
let index = program.choose_context(Some(record.to_string())); | ||
assert_eq!(i, index); | ||
} | ||
} | ||
|
||
#[test] | ||
fn fs_config() { | ||
let program = ArtifactConfiguration::new(CONTEXTS); | ||
let collection = String::from("test"); | ||
let config = program.fs_config(collection.clone()); | ||
|
||
let json_base_path = String::from("./.data/output/github/"); | ||
assert_eq!( | ||
config.json_collection_path, | ||
json_base_path + &collection + "/" | ||
); | ||
|
||
let partial_artifact_base_path = "/.data/artifact/github/"; | ||
assert!(config | ||
.artifact_base_path | ||
.contains(partial_artifact_base_path)); | ||
|
||
let artifact_file_name_prefix = String::from("github-"); | ||
assert_eq!( | ||
config.artifact_file_name, | ||
artifact_file_name_prefix.clone() + &collection + ".tar.gz" | ||
); | ||
|
||
assert_eq!( | ||
config.encrypted_artifact_file_name, | ||
artifact_file_name_prefix + &collection + ".tar.gz.gpg" | ||
) | ||
} | ||
} |
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 |
---|---|---|
|
@@ -188,3 +188,6 @@ impl<'a> DataPipelineConfiguration<'a> { | |
String::new() | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests; |
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,25 @@ | ||
mod data_pipeline_configuration { | ||
use crate::data_pipeline::{ | ||
artifact::CONTEXTS, configuration::DataPipelineConfiguration, mongo::COLLECTIONS, | ||
}; | ||
|
||
#[test] | ||
fn choose_context() { | ||
let program = DataPipelineConfiguration::new(CONTEXTS, COLLECTIONS); | ||
let contexts = program.contexts; | ||
for (i, record) in contexts.iter().enumerate() { | ||
let index = program.choose_context(Some(i.to_string())); | ||
assert_eq!(contexts.get(index), Some(record)); | ||
} | ||
} | ||
|
||
#[test] | ||
fn choose_collection() { | ||
let program = DataPipelineConfiguration::new(CONTEXTS, COLLECTIONS); | ||
let collections = program.collections; | ||
for (i, record) in collections.iter().enumerate() { | ||
let index = program.choose_collection(Some(i.to_string())); | ||
assert_eq!(collections.get(index), Some(record)); | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
mod mongo_db_configuration { | ||
use crate::data_pipeline::mongo::{configuration::MongoDbConfiguration, COLLECTIONS}; | ||
|
||
#[test] | ||
fn collections() { | ||
let program = MongoDbConfiguration::new(COLLECTIONS); | ||
let collections = program.collections; | ||
for (i, record) in collections.iter().enumerate() { | ||
let index = program.choose_collection(Some(record.to_string())); | ||
assert_eq!(i, index); | ||
} | ||
} | ||
|
||
#[test] | ||
fn fs_config() { | ||
let program = MongoDbConfiguration::new(COLLECTIONS); | ||
let collection = String::from("test"); | ||
let config = program.fs_config(collection.clone()); | ||
|
||
let json_base_path = String::from("/.data/output/github/"); | ||
let partial_json_data_dir = json_base_path + &collection + "/"; | ||
assert!(config.json_data_dir.contains(&partial_json_data_dir)); | ||
} | ||
} |