use itertools::Itertools;
use native_db::db_type::Result;
use native_db::*;
use native_model::{native_model, Model};
use paste::paste;
use serde::{Deserialize, Serialize};
use uuid::{uuid, Uuid};
macro_rules! create_test {
($struct_name:ident, $id_type:ty, $id_value:expr, $expected_id_type:ty, $expected_id_value:expr, $non_expected_id_type:ty, $non_expected_id_value:expr) => {
#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
#[native_model(id = 1, version = 1)]
#[native_db]
#[allow(non_camel_case_types)]
struct $struct_name {
#[primary_key]
id: $id_type,
#[secondary_key(unique)]
sk: $id_type,
}
#[test]
#[allow(non_camel_case_types)]
fn $struct_name() {
let item = $struct_name {
id: $id_value,
sk: $id_value,
};
let mut models = Models::new();
models.define::<$struct_name>().unwrap();
let db = Builder::new().create_in_memory(&models).unwrap();
let rw = db.rw_transaction().unwrap();
rw.insert(item.clone()).unwrap();
rw.commit().unwrap();
let r = db.r_transaction().unwrap();
// Get primary key
let expected_id: $expected_id_type = $expected_id_value;
let result_item = r.get().primary(expected_id).unwrap().unwrap();
assert_eq!(item, result_item);
let non_expected_id: $non_expected_id_type = $non_expected_id_value;
let result_item: Result