v0.1.3-pre.003
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
// file: crates/ksp-config-lib/tests/public_api.rs
|
||||
// version: 2
|
||||
// version: 3
|
||||
|
||||
//! Integration tests for the public `ksp-config-lib` bootstrap contract.
|
||||
//! Integration tests for the public `ksp-config-lib` bootstrap and logical file registry contracts.
|
||||
|
||||
#[test]
|
||||
fn bootstrap_contract_is_available_from_crate_root() {
|
||||
@@ -40,3 +40,35 @@ fn cli_bootstrap_parser_is_available_from_crate_root() {
|
||||
assert_eq!(options.schema_path(), std::path::Path::new("consumer-schemas"));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn logical_file_registry_is_available_from_crate_root() {
|
||||
let args = [
|
||||
std::ffi::OsString::from("consumer"),
|
||||
std::ffi::OsString::from("--filemap=cfg.std.logging=consumer.logging.json"),
|
||||
std::ffi::OsString::from("--filemap=schema.std.logging=consumer.logging.schema.json"),
|
||||
];
|
||||
let registry = ksp_config_lib::ConfigFileRegistry::from_args(&args);
|
||||
let bootstrap = ksp_config_lib::ConfigBootstrapOptions::from_paths("consumer-config", "consumer-schemas");
|
||||
let logging_id = ksp_config_lib::ConfigFileId::new(ksp_config_lib::FILE_ID_STD_LOGGING);
|
||||
let schema_id = ksp_config_lib::ConfigFileId::new(ksp_config_lib::FILE_ID_SCHEMA_STD_LOGGING);
|
||||
assert!(registry.is_ok(), "public registry should accept known filemap overrides: {registry:?}");
|
||||
assert!(bootstrap.is_ok(), "bootstrap paths should remain available: {bootstrap:?}");
|
||||
assert!(logging_id.is_ok(), "public logging file_id should be valid: {logging_id:?}");
|
||||
assert!(schema_id.is_ok(), "public schema file_id should be valid: {schema_id:?}");
|
||||
if let (std::result::Result::Ok(registry), std::result::Result::Ok(bootstrap), std::result::Result::Ok(logging_id), std::result::Result::Ok(schema_id)) =
|
||||
(registry, bootstrap, logging_id, schema_id)
|
||||
{
|
||||
let logging = registry.resolve_path(&bootstrap, &logging_id);
|
||||
let schema = registry.resolve_path(&bootstrap, &schema_id);
|
||||
assert!(logging.is_ok(), "public logging path should resolve: {logging:?}");
|
||||
assert!(schema.is_ok(), "public schema path should resolve: {schema:?}");
|
||||
if let std::result::Result::Ok(logging) = logging {
|
||||
assert_eq!(logging, std::path::PathBuf::from("consumer-config/consumer.logging.json"));
|
||||
}
|
||||
if let std::result::Result::Ok(schema) = schema {
|
||||
assert_eq!(schema, std::path::PathBuf::from("consumer-schemas/consumer.logging.schema.json"));
|
||||
}
|
||||
assert_eq!(ksp_config_lib::ARG_FILE_MAP, "--filemap");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user