Skip to content

Commit efa7ca1

Browse files
committed
chore: rename id test helper function
1 parent 8ecb448 commit efa7ca1

19 files changed

+202
-110
lines changed

packages/cipherstash-proxy-integration/src/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub const TEST_SCHEMA_SQL: &str = include_str!(concat!("../../../tests/sql/schem
1717

1818
static INIT: Once = Once::new();
1919

20-
pub fn id() -> i64 {
20+
pub fn random_id() -> i64 {
2121
use rand::Rng;
2222
let mut rng = rand::rng();
2323
rng.random_range(1..=i64::MAX)

packages/cipherstash-proxy-integration/src/decrypt/insert_returning.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
mod tests {
33
use chrono::NaiveDate;
44

5-
use crate::common::{clear, connect_with_tls, id, trace, PROXY};
5+
use crate::common::{clear, connect_with_tls, random_id, trace, PROXY};
66

77
#[tokio::test]
88
async fn decrypt_insert_returning_with_different_column_order() {

packages/cipherstash-proxy-integration/src/extended_protocol_error_messages.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
mod tests {
33
use tracing::{debug, info};
44

5-
use crate::common::{clear, connect_with_tls, id, reset_schema, trace, PROXY};
5+
use crate::common::{clear, connect_with_tls, random_id, reset_schema, trace, PROXY};
66

77
struct Reset;
88

@@ -24,7 +24,7 @@ mod tests {
2424

2525
let _reset = Reset;
2626

27-
let id = id();
27+
let id = random_id();
2828

2929
let client = connect_with_tls(PROXY).await;
3030

@@ -55,7 +55,7 @@ mod tests {
5555

5656
// Create a record
5757
// If select returns no results, no configuration is required
58-
let id = id();
58+
let id = random_id();
5959
let encrypted_text = "[email protected]";
6060

6161
let sql = "INSERT INTO unconfigured (id, encrypted_unconfigured) VALUES ($1, $2)";
@@ -82,7 +82,7 @@ mod tests {
8282

8383
let client = connect_with_tls(PROXY).await;
8484

85-
let id = id();
85+
let id = random_id();
8686
// let encrypted_date = NaiveDate::parse_from_str("2025-01-01", "%Y-%m-%d").unwrap();
8787
let encrypted_date: i32 = 2025;
8888

@@ -111,7 +111,7 @@ mod tests {
111111

112112
// Create a record
113113
// If select returns no results, no configuration is required
114-
let id = id();
114+
let id = random_id();
115115
let encrypted_text = "[email protected]";
116116

117117
let sql = "INSERT INTO encrypted id, encrypted_text VALUES ($1, $2)";

packages/cipherstash-proxy-integration/src/map_concat.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
#[cfg(test)]
22
mod tests {
3-
use crate::common::{clear, connect_with_tls, id, PROXY};
3+
use crate::common::{clear, connect_with_tls, random_id, PROXY};
44

55
#[tokio::test]
66
async fn map_concat_regression() {
77
let client = connect_with_tls(PROXY).await;
88

99
clear().await;
1010

11-
let id = id();
11+
let id = random_id();
1212
let encrypted_text = "[email protected]";
1313

1414
let sql = "INSERT INTO encrypted (id, encrypted_text) VALUES ($1, $2)";

packages/cipherstash-proxy-integration/src/map_literals.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
#[cfg(test)]
22
mod tests {
3-
use crate::common::{clear, connect_with_tls, id, PROXY};
3+
use crate::common::{clear, connect_with_tls, random_id, PROXY};
44

55
#[tokio::test]
66
async fn map_literal() {
77
clear().await;
88

99
let client = connect_with_tls(PROXY).await;
1010

11-
let id = id();
11+
let id = random_id();
1212
let encrypted_text = "[email protected]";
1313

1414
let sql =
@@ -28,7 +28,7 @@ mod tests {
2828

2929
let client = connect_with_tls(PROXY).await;
3030

31-
let id = id();
31+
let id = random_id();
3232
let encrypted_text = "[email protected]";
3333
let int2: i16 = 1;
3434

@@ -51,7 +51,7 @@ mod tests {
5151

5252
let client = connect_with_tls(PROXY).await;
5353

54-
let id = id();
54+
let id = random_id();
5555
let encrypted_jsonb = serde_json::json!({"key": "value"});
5656

5757
let sql = format!(
@@ -80,7 +80,7 @@ mod tests {
8080

8181
let client = connect_with_tls(PROXY).await;
8282

83-
let id = id();
83+
let id = random_id();
8484

8585
let sql =
8686
format!("INSERT INTO encrypted (id, encrypted_int8) VALUES ({id}, {id}) RETURNING id, encrypted_int8");
@@ -103,7 +103,7 @@ mod tests {
103103
let client = connect_with_tls(PROXY).await;
104104

105105
let sql =
106-
format!("INSERT INTO encrypted (id, encrypted_text) VALUES ({}, 'a'), ({}, 'a') RETURNING encrypted_text", id(), id());
106+
format!("INSERT INTO encrypted (id, encrypted_text) VALUES ({}, 'a'), ({}, 'a') RETURNING encrypted_text", random_id(), random_id());
107107
let rows = client.query(&sql, &[]).await.unwrap();
108108

109109
let actual = rows.iter().map(|row| row.get(0)).collect::<Vec<&str>>();

packages/cipherstash-proxy-integration/src/map_match_index.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#[cfg(test)]
22
mod tests {
3-
use crate::common::{clear, connect_with_tls, id, trace, PROXY};
3+
use crate::common::{clear, connect_with_tls, random_id, trace, PROXY};
44

55
#[tokio::test]
66
async fn map_match_index_text() {
@@ -10,7 +10,7 @@ mod tests {
1010

1111
let client = connect_with_tls(PROXY).await;
1212

13-
let id = id();
13+
let id = random_id();
1414
let encrypted_text = "[email protected]";
1515

1616
let sql = "INSERT INTO encrypted (id, encrypted_text) VALUES ($1, $2)";

packages/cipherstash-proxy-integration/src/map_nulls.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
#[cfg(test)]
22
mod tests {
3+
use crate::common::{clear, connect_with_tls, random_id, trace, PROXY};
34
use chrono::NaiveDate;
45

5-
use crate::common::{clear, connect_with_tls, id, trace, PROXY};
6-
76
#[tokio::test]
87
async fn map_insert_null_param() {
98
trace();
109

1110
let client = connect_with_tls(PROXY).await;
1211

13-
let id = id();
12+
let id = random_id();
1413
let encrypted_text: Option<String> = None;
1514

1615
let sql = "INSERT INTO encrypted (id, encrypted_text) VALUES ($1, $2)";
@@ -33,7 +32,7 @@ mod tests {
3332

3433
let client = connect_with_tls(PROXY).await;
3534

36-
let id = id();
35+
let id = random_id();
3736
let encrypted_text = "[email protected]";
3837

3938
let sql = "INSERT INTO encrypted (id, encrypted_text) VALUES ($1, $2)";
@@ -71,7 +70,7 @@ mod tests {
7170

7271
let client = connect_with_tls(PROXY).await;
7372

74-
let id = id();
73+
let id = random_id();
7574

7675
let sql = "INSERT INTO encrypted (id, encrypted_text) VALUES ($1, NULL)";
7776
client.query(sql, &[&id]).await.unwrap();
@@ -96,7 +95,7 @@ mod tests {
9695

9796
let client = connect_with_tls(PROXY).await;
9897

99-
let id = id();
98+
let id = random_id();
10099
let encrypted_int2: i16 = 42;
101100

102101
let sql =
@@ -128,7 +127,7 @@ mod tests {
128127

129128
let client = connect_with_tls(PROXY).await;
130129

131-
let id = id();
130+
let id = random_id();
132131
let plaintext: Option<String> = None;
133132
let plaintext_date: Option<NaiveDate> = None;
134133
let encrypted_text: Option<String> = None;

0 commit comments

Comments
 (0)