Skip to content

Commit 6d43ab5

Browse files
committed
refactor(tests): improve ORE variant test coverage and consistency
- Fix inconsistent QueryAssertion chaining pattern (use direct .count() instead of .returns_rows().await.count()) - Add CLLW_U64_8 comparison operator tests: <, >, >= - Add CLLW_VAR_8 comparison operator tests: <, >, >= - Extends ORE variant coverage from 8 to 14 tests - All CLLW schemes now have full comparison operator coverage Addresses code review feedback.
1 parent 7fe1cba commit 6d43ab5

File tree

1 file changed

+106
-16
lines changed

1 file changed

+106
-16
lines changed

tests/sqlx/tests/ore_equality_tests.rs

Lines changed: 106 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,7 @@ async fn ore64_equality_operator_finds_match(pool: PgPool) -> Result<()> {
2121
encrypted
2222
);
2323

24-
QueryAssertion::new(&pool, &sql)
25-
.returns_rows()
26-
.await
27-
.count(1)
28-
.await;
24+
QueryAssertion::new(&pool, &sql).count(1).await;
2925

3026
Ok(())
3127
}
@@ -61,11 +57,7 @@ async fn ore_cllw_u64_8_equality_finds_match(pool: PgPool) -> Result<()> {
6157
encrypted
6258
);
6359

64-
QueryAssertion::new(&pool, &sql)
65-
.returns_rows()
66-
.await
67-
.count(1)
68-
.await;
60+
QueryAssertion::new(&pool, &sql).count(1).await;
6961

7062
Ok(())
7163
}
@@ -100,11 +92,7 @@ async fn ore_cllw_var_8_equality_finds_match(pool: PgPool) -> Result<()> {
10092
encrypted
10193
);
10294

103-
QueryAssertion::new(&pool, &sql)
104-
.returns_rows()
105-
.await
106-
.count(1)
107-
.await;
95+
QueryAssertion::new(&pool, &sql).count(1).await;
10896

10997
Ok(())
11098
}
@@ -127,9 +115,26 @@ async fn ore_cllw_var_8_inequality_finds_non_matches(pool: PgPool) -> Result<()>
127115
}
128116

129117
// ============================================================================
130-
// Task 9: ORE Comparison Variants (<= with CLLW schemes)
118+
// Task 9: ORE Comparison Variants (CLLW schemes)
131119
// ============================================================================
132120

121+
#[sqlx::test]
122+
async fn ore_cllw_u64_8_less_than(pool: PgPool) -> Result<()> {
123+
// Test: e < e with ORE CLLW_U64_8 scheme
124+
// Extends coverage beyond original SQL tests for completeness
125+
126+
let encrypted = get_ore_encrypted(&pool, 42).await?;
127+
128+
let sql = format!(
129+
"SELECT id FROM ore WHERE e < '{}'::eql_v2_encrypted",
130+
encrypted
131+
);
132+
133+
QueryAssertion::new(&pool, &sql).count(41).await;
134+
135+
Ok(())
136+
}
137+
133138
#[sqlx::test]
134139
async fn ore_cllw_u64_8_less_than_or_equal(pool: PgPool) -> Result<()> {
135140
// Test: e <= e with ORE CLLW_U64_8 scheme
@@ -148,6 +153,57 @@ async fn ore_cllw_u64_8_less_than_or_equal(pool: PgPool) -> Result<()> {
148153
Ok(())
149154
}
150155

156+
#[sqlx::test]
157+
async fn ore_cllw_u64_8_greater_than(pool: PgPool) -> Result<()> {
158+
// Test: e > e with ORE CLLW_U64_8 scheme
159+
// Extends coverage beyond original SQL tests for completeness
160+
161+
let encrypted = get_ore_encrypted(&pool, 42).await?;
162+
163+
let sql = format!(
164+
"SELECT id FROM ore WHERE e > '{}'::eql_v2_encrypted",
165+
encrypted
166+
);
167+
168+
QueryAssertion::new(&pool, &sql).count(57).await;
169+
170+
Ok(())
171+
}
172+
173+
#[sqlx::test]
174+
async fn ore_cllw_u64_8_greater_than_or_equal(pool: PgPool) -> Result<()> {
175+
// Test: e >= e with ORE CLLW_U64_8 scheme
176+
// Extends coverage beyond original SQL tests for completeness
177+
178+
let encrypted = get_ore_encrypted(&pool, 42).await?;
179+
180+
let sql = format!(
181+
"SELECT id FROM ore WHERE e >= '{}'::eql_v2_encrypted",
182+
encrypted
183+
);
184+
185+
QueryAssertion::new(&pool, &sql).count(58).await;
186+
187+
Ok(())
188+
}
189+
190+
#[sqlx::test]
191+
async fn ore_cllw_var_8_less_than(pool: PgPool) -> Result<()> {
192+
// Test: e < e with ORE CLLW_VAR_8 scheme
193+
// Extends coverage beyond original SQL tests for completeness
194+
195+
let encrypted = get_ore_encrypted(&pool, 42).await?;
196+
197+
let sql = format!(
198+
"SELECT id FROM ore WHERE e < '{}'::eql_v2_encrypted",
199+
encrypted
200+
);
201+
202+
QueryAssertion::new(&pool, &sql).count(41).await;
203+
204+
Ok(())
205+
}
206+
151207
#[sqlx::test]
152208
async fn ore_cllw_var_8_less_than_or_equal(pool: PgPool) -> Result<()> {
153209
// Test: e <= e with ORE CLLW_VAR_8 scheme
@@ -165,3 +221,37 @@ async fn ore_cllw_var_8_less_than_or_equal(pool: PgPool) -> Result<()> {
165221

166222
Ok(())
167223
}
224+
225+
#[sqlx::test]
226+
async fn ore_cllw_var_8_greater_than(pool: PgPool) -> Result<()> {
227+
// Test: e > e with ORE CLLW_VAR_8 scheme
228+
// Extends coverage beyond original SQL tests for completeness
229+
230+
let encrypted = get_ore_encrypted(&pool, 42).await?;
231+
232+
let sql = format!(
233+
"SELECT id FROM ore WHERE e > '{}'::eql_v2_encrypted",
234+
encrypted
235+
);
236+
237+
QueryAssertion::new(&pool, &sql).count(57).await;
238+
239+
Ok(())
240+
}
241+
242+
#[sqlx::test]
243+
async fn ore_cllw_var_8_greater_than_or_equal(pool: PgPool) -> Result<()> {
244+
// Test: e >= e with ORE CLLW_VAR_8 scheme
245+
// Extends coverage beyond original SQL tests for completeness
246+
247+
let encrypted = get_ore_encrypted(&pool, 42).await?;
248+
249+
let sql = format!(
250+
"SELECT id FROM ore WHERE e >= '{}'::eql_v2_encrypted",
251+
encrypted
252+
);
253+
254+
QueryAssertion::new(&pool, &sql).count(58).await;
255+
256+
Ok(())
257+
}

0 commit comments

Comments
 (0)