Skip to content

Commit 87f411b

Browse files
author
Zoran Cvetkov
committed
test multiple entities
1 parent a226e5b commit 87f411b

File tree

1 file changed

+23
-8
lines changed

1 file changed

+23
-8
lines changed

store/test-store/tests/postgres/writable.rs

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ async fn insert_count(
125125
count: u8,
126126
counter_type: &EntityType,
127127
id: &str,
128+
id2: &str,
128129
) {
129130
let count_key_local = |id: &str| counter_type.parse_key(id).unwrap();
130131
let data = entity! { TEST_SUBGRAPH_SCHEMA =>
@@ -135,9 +136,22 @@ async fn insert_count(
135136
key: count_key_local(&data.get("id").unwrap().to_string()),
136137
data,
137138
};
138-
transact_entity_operations(store, deployment, block_pointer(block), vec![entity_op])
139-
.await
140-
.unwrap();
139+
let data = entity! { TEST_SUBGRAPH_SCHEMA =>
140+
id: id2,
141+
count :count as i32,
142+
};
143+
let entity_op2 = EntityOperation::Set {
144+
key: count_key_local(&data.get("id").unwrap().to_string()),
145+
data,
146+
};
147+
transact_entity_operations(
148+
store,
149+
deployment,
150+
block_pointer(block),
151+
vec![entity_op, entity_op2],
152+
)
153+
.await
154+
.unwrap();
141155
}
142156

143157
async fn insert_count_mutable(
@@ -146,7 +160,7 @@ async fn insert_count_mutable(
146160
block: u8,
147161
count: u8,
148162
) {
149-
insert_count(store, deployment, block, count, &COUNTER_TYPE, "1").await;
163+
insert_count(store, deployment, block, count, &COUNTER_TYPE, "1", "2").await;
150164
}
151165

152166
async fn insert_count_immutable(
@@ -161,7 +175,8 @@ async fn insert_count_immutable(
161175
block,
162176
count,
163177
&COUNTER2_TYPE,
164-
&(block / 2).to_string(),
178+
&(block).to_string(),
179+
&(block + 1).to_string(),
165180
)
166181
.await;
167182
}
@@ -353,21 +368,21 @@ async fn read_range(
353368
&COUNTER2_TYPE
354369
};
355370
let e = writable.get_range(et, br).unwrap();
356-
e.len()
371+
e.iter().map(|(_, v)| v.iter()).flatten().count()
357372
}
358373

359374
#[test]
360375
fn read_range_mutable() {
361376
run_test(|store, writable, deployment| async move {
362377
let num_entities = read_range(store, writable, deployment, true).await;
363-
assert_eq!(num_entities, 3) // TODO: fix it - it should be 2 as the range is open
378+
assert_eq!(num_entities, 6) // TODO: fix it - it should be 4 as the range is open
364379
})
365380
}
366381

367382
#[test]
368383
fn read_range_immutable() {
369384
run_test(|store, writable, deployment| async move {
370385
let num_entities = read_range(store, writable, deployment, false).await;
371-
assert_eq!(num_entities, 3) // TODO: fix it - it should be 2 as the range is open
386+
assert_eq!(num_entities, 6) // TODO: fix it - it should be 4 as the range is open
372387
})
373388
}

0 commit comments

Comments
 (0)