use crate::utils::{open_database, tmpdir};
use leveldb::database::property::Property;

#[test]
fn test_valid_property() {
    let tmp = tmpdir("property");
    let database = open_database(tmp.path(), true);

    // Test with a valid property name
    let result = database.get_property("leveldb.stats");

    assert!(result.is_ok());
    assert!(result.unwrap().is_some());
}

#[test]
fn test_invalid_properties() {
    let tmp = tmpdir("property");
    let database = open_database(tmp.path(), true);

    // Test various invalid property names
    let test_cases = [
        "not.exist",      // Non-existent property
        "",               // Empty string
        "leveldb. stats", // Property name with spaces
        "leveldb.",       // Incomplete property name
        "leveldb.stats ", // Trailing space
        " leveldb.stats", // Leading space
    ];

    for property_name in test_cases {
        let result = database.get_property(property_name);
        assert!(result.is_ok(), "Failed for property: '{}'", property_name);
        assert!(
            result.unwrap().is_none(),
            "Property '{}' should not exist",
            property_name
        );
    }
}
