fmt, fixes and additions

This commit is contained in:
timurgordon
2025-06-19 13:18:10 +03:00
parent 6b3cbfc4b2
commit e91a44ce37
86 changed files with 5292 additions and 2844 deletions

View File

@@ -1,5 +1,5 @@
use heromodels_derive::model;
use serde::{Serialize, Deserialize};
use serde::{Deserialize, Serialize};
// Define the necessary structs and traits for testing
#[derive(Debug, Clone, Serialize, Deserialize)]
@@ -46,10 +46,10 @@ pub trait Index {
#[model]
struct TestUser {
base_data: BaseModelData,
#[index]
username: String,
#[index]
is_active: bool,
}
@@ -59,10 +59,10 @@ struct TestUser {
#[model]
struct TestUserWithCustomIndex {
base_data: BaseModelData,
#[index(name = "custom_username")]
username: String,
#[index]
is_active: bool,
}
@@ -70,13 +70,13 @@ struct TestUserWithCustomIndex {
#[test]
fn test_basic_model() {
assert_eq!(TestUser::db_prefix(), "test_user");
let user = TestUser {
base_data: BaseModelData::new(1),
username: "test".to_string(),
is_active: true,
};
let keys = user.db_keys();
assert_eq!(keys.len(), 2);
assert_eq!(keys[0].name, "username");
@@ -92,10 +92,10 @@ fn test_custom_index_name() {
username: "test".to_string(),
is_active: true,
};
// Check that the Username struct uses the custom index name
assert_eq!(Username::key(), "custom_username");
// Check that the db_keys method returns the correct keys
let keys = user.db_keys();
assert_eq!(keys.len(), 2);
@@ -103,4 +103,4 @@ fn test_custom_index_name() {
assert_eq!(keys[0].value, "test");
assert_eq!(keys[1].name, "is_active");
assert_eq!(keys[1].value, "true");
}
}