Files
khadhroony-solana-project/crates/ksp-config-lib/tests/public_api.rs

43 lines
1.9 KiB
Rust

// file: crates/ksp-config-lib/tests/public_api.rs
// version: 2
//! Integration tests for the public `ksp-config-lib` bootstrap contract.
#[test]
fn bootstrap_contract_is_available_from_crate_root() {
let result = ksp_config_lib::ConfigBootstrapOptions::defaults();
assert!(result.is_ok(), "default bootstrap options should be available: {result:?}");
if let std::result::Result::Ok(options) = result {
assert_eq!(options.cfg_path(), std::path::Path::new(ksp_config_lib::DEFAULT_CFG_PATH));
assert_eq!(options.schema_path(), std::path::Path::new(ksp_config_lib::DEFAULT_SCHEMA_PATH));
assert_eq!(ksp_config_lib::ARG_CFG_PATH, "--cfgpath");
assert_eq!(ksp_config_lib::ARG_SCHEMA_PATH, "--schemapath");
}
}
#[test]
fn programmatic_bootstrap_paths_are_independent() {
let result = ksp_config_lib::ConfigBootstrapOptions::from_paths("runtime-config", "runtime-schemas");
assert!(result.is_ok(), "programmatic bootstrap paths should be valid: {result:?}");
if let std::result::Result::Ok(options) = result {
assert_eq!(options.cfg_path(), std::path::Path::new("runtime-config"));
assert_eq!(options.schema_path(), std::path::Path::new("runtime-schemas"));
}
}
#[test]
fn cli_bootstrap_parser_is_available_from_crate_root() {
let args = [
std::ffi::OsString::from("consumer"),
std::ffi::OsString::from("--cfgpath=consumer-config"),
std::ffi::OsString::from("--schemapath"),
std::ffi::OsString::from("consumer-schemas"),
];
let result = ksp_config_lib::ConfigBootstrapOptions::from_args(&args);
assert!(result.is_ok(), "public bootstrap parser should accept KSP path arguments: {result:?}");
if let std::result::Result::Ok(options) = result {
assert_eq!(options.cfg_path(), std::path::Path::new("consumer-config"));
assert_eq!(options.schema_path(), std::path::Path::new("consumer-schemas"));
}
}