Skip to content

Commit 5762750

Browse files
Run cargo fmt
1 parent 2e75291 commit 5762750

16 files changed

+111
-138
lines changed

plrust-tests/src/alter.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
/*
32
Portions Copyright 2020-2021 ZomboDB, LLC.
43
Portions Copyright 2021-2023 Technology Concepts & Design, Inc. <[email protected]>
@@ -11,8 +10,7 @@ Use of this source code is governed by the PostgreSQL license that can be found
1110
#[cfg(any(test, feature = "pg_test"))]
1211
#[pgrx::pg_schema]
1312
mod tests {
14-
use pgrx:: prelude::*;
15-
13+
use pgrx::prelude::*;
1614

1715
#[pg_test]
1816
#[search_path(@extschema@)]
@@ -41,5 +39,4 @@ mod tests {
4139
Spi::run(definition)?;
4240
Spi::run("ALTER FUNCTION cant_change_strict_on() RETURNS NULL ON NULL INPUT")
4341
}
44-
45-
}
42+
}

plrust-tests/src/argument.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
/*
32
Portions Copyright 2020-2021 ZomboDB, LLC.
43
Portions Copyright 2021-2023 Technology Concepts & Design, Inc. <[email protected]>
@@ -11,7 +10,7 @@ Use of this source code is governed by the PostgreSQL license that can be found
1110
#[cfg(any(test, feature = "pg_test"))]
1211
#[pgrx::pg_schema]
1312
mod tests {
14-
use pgrx:: prelude::*;
13+
use pgrx::prelude::*;
1514

1615
#[pg_test]
1716
#[search_path(@extschema@)]
@@ -64,9 +63,9 @@ mod tests {
6463
#[pg_test]
6564
#[search_path(@extschema@)]
6665
#[should_panic(
67-
expected = "is an invalid Rust identifier and cannot be used as an argument name"
66+
expected = "is an invalid Rust identifier and cannot be used as an argument name"
6867
)]
6968
fn invalid_arg_identifier() -> spi::Result<()> {
7069
Spi::run("CREATE FUNCTION invalid_arg_identifier(\"this isn't a valid rust identifier\" int) RETURNS int LANGUAGE plrust as $$ Ok(None) $$;")
7170
}
72-
}
71+
}

plrust-tests/src/basic.rs

-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
/*
32
Portions Copyright 2020-2021 ZomboDB, LLC.
43
Portions Copyright 2021-2023 Technology Concepts & Design, Inc. <[email protected]>
@@ -13,7 +12,6 @@ Use of this source code is governed by the PostgreSQL license that can be found
1312
mod tests {
1413
use pgrx::{datum::IntoDatum, prelude::*};
1514

16-
1715
#[pg_test]
1816
#[search_path(@extschema@)]
1917
fn plrust_basic() -> spi::Result<()> {
@@ -40,7 +38,6 @@ mod tests {
4038
Ok(())
4139
}
4240

43-
4441
#[pg_test]
4542
#[search_path(@extschema@)]
4643
fn plrust_update() -> spi::Result<()> {

plrust-tests/src/blocked_code.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
/*
32
Portions Copyright 2020-2021 ZomboDB, LLC.
43
Portions Copyright 2021-2023 Technology Concepts & Design, Inc. <[email protected]>
@@ -11,7 +10,7 @@ Use of this source code is governed by the PostgreSQL license that can be found
1110
#[cfg(any(test, feature = "pg_test"))]
1211
#[pgrx::pg_schema]
1312
mod tests {
14-
use pgrx:: prelude::*;
13+
use pgrx::prelude::*;
1514

1615
#[pg_test]
1716
#[search_path(@ extschema @)]
@@ -180,4 +179,4 @@ mod tests {
180179
assert_eq!(Ok(Some(1)), result);
181180
Ok(())
182181
}
183-
}
182+
}

plrust-tests/src/borrow_mut_error.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Use of this source code is governed by the PostgreSQL license that can be found
1010
#[cfg(any(test, feature = "pg_test"))]
1111
#[pgrx::pg_schema]
1212
mod tests {
13-
use pgrx:: prelude::*;
13+
use pgrx::prelude::*;
1414

1515
#[pg_test]
1616
#[should_panic(expected = "issue78 works")]
@@ -53,5 +53,4 @@ mod tests {
5353
assert_eq!(Ok(Some(1)), Spi::get_one::<i32>("SELECT fn1(1)"));
5454
Ok(())
5555
}
56-
57-
}
56+
}

plrust-tests/src/ddl.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
/*
32
Portions Copyright 2020-2021 ZomboDB, LLC.
43
Portions Copyright 2021-2023 Technology Concepts & Design, Inc. <[email protected]>
@@ -11,7 +10,7 @@ Use of this source code is governed by the PostgreSQL license that can be found
1110
#[cfg(any(test, feature = "pg_test"))]
1211
#[pgrx::pg_schema]
1312
mod tests {
14-
use pgrx:: prelude::*;
13+
use pgrx::prelude::*;
1514

1615
#[pg_test]
1716
#[search_path(@extschema@)]
@@ -90,4 +89,4 @@ mod tests {
9089
assert_eq!(Ok(Some(2)), Spi::get_one("SELECT replace_me()"));
9190
Ok(())
9291
}
93-
}
92+
}

plrust-tests/src/lib.rs

+13-15
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1+
mod alter;
2+
mod argument;
13
mod basic;
2-
mod versioning;
3-
mod dependencies;
4-
mod return_values;
5-
mod ddl;
64
mod blocked_code;
7-
mod recursion;
8-
mod matches;
9-
mod argument;
10-
mod range;
11-
mod user_defined_types;
12-
mod time_and_dates;
135
mod borrow_mut_error;
6+
mod ddl;
7+
mod dependencies;
8+
mod matches;
149
mod panics;
15-
mod alter;
10+
mod range;
11+
mod recursion;
12+
mod return_values;
1613
mod round_trip;
14+
mod time_and_dates;
1715
mod trusted;
16+
mod user_defined_types;
17+
mod versioning;
1818

1919
use pgrx::prelude::*;
2020

@@ -32,7 +32,7 @@ Use of this source code is governed by the PostgreSQL license that can be found
3232
#[cfg(any(test, feature = "pg_test"))]
3333
#[pgrx::pg_schema]
3434
mod tests {
35-
use pgrx::{prelude::*};
35+
use pgrx::prelude::*;
3636

3737
// Bootstrap a testing table for non-immutable functions
3838
extension_sql!(
@@ -62,8 +62,7 @@ pub mod pg_test {
6262
static PLRUST_ALLOWED_DEPENDENCIES_FILE_NAME: &str = "allowed_deps.toml";
6363
static PLRUST_ALLOWED_DEPENDENCIES_FILE_DIRECTORY: Lazy<TempDir> = Lazy::new(|| {
6464
use std::io::Write;
65-
let temp_allowed_deps_dir =
66-
tempdir().expect("Couldnt create tempdir");
65+
let temp_allowed_deps_dir = tempdir().expect("Couldnt create tempdir");
6766

6867
let file_path = temp_allowed_deps_dir
6968
.path()
@@ -107,4 +106,3 @@ plutonium = "*"
107106
]
108107
}
109108
}
110-

plrust-tests/src/matches.rs

+52-53
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
/*
32
Portions Copyright 2020-2021 ZomboDB, LLC.
43
Portions Copyright 2021-2023 Technology Concepts & Design, Inc. <[email protected]>
@@ -11,44 +10,44 @@ Use of this source code is governed by the PostgreSQL license that can be found
1110
#[cfg(any(test, feature = "pg_test"))]
1211
#[pgrx::pg_schema]
1312
mod tests {
14-
use pgrx:: prelude::*;
13+
use pgrx::prelude::*;
1514

1615
#[pg_test]
17-
#[search_path(@extschema@)]
18-
fn plrust_call_1st() -> spi::Result<()> {
19-
let definition = r#"
16+
#[search_path(@extschema@)]
17+
fn plrust_call_1st() -> spi::Result<()> {
18+
let definition = r#"
2019
CREATE FUNCTION ret_1st(a int, b int)
2120
RETURNS int AS
2221
$$
2322
Ok(a)
2423
$$ LANGUAGE plrust;
2524
"#;
26-
Spi::run(definition)?;
27-
let result_1 = Spi::get_one::<i32>("SELECT ret_1st(1, 2);\n");
28-
assert_eq!(Ok(Some(1)), result_1); // may get: Some(1)
29-
Ok(())
30-
}
25+
Spi::run(definition)?;
26+
let result_1 = Spi::get_one::<i32>("SELECT ret_1st(1, 2);\n");
27+
assert_eq!(Ok(Some(1)), result_1); // may get: Some(1)
28+
Ok(())
29+
}
3130

32-
#[pg_test]
33-
#[search_path(@extschema@)]
34-
fn plrust_call_2nd() -> spi::Result<()> {
35-
let definition = r#"
31+
#[pg_test]
32+
#[search_path(@extschema@)]
33+
fn plrust_call_2nd() -> spi::Result<()> {
34+
let definition = r#"
3635
CREATE FUNCTION ret_2nd(a int, b int)
3736
RETURNS int AS
3837
$$
3938
Ok(b)
4039
$$ LANGUAGE plrust;
4140
"#;
42-
Spi::run(definition)?;
43-
let result_2 = Spi::get_one::<i32>("SELECT ret_2nd(1, 2);\n");
44-
assert_eq!(Ok(Some(2)), result_2); // may get: Some(2)
45-
Ok(())
46-
}
41+
Spi::run(definition)?;
42+
let result_2 = Spi::get_one::<i32>("SELECT ret_2nd(1, 2);\n");
43+
assert_eq!(Ok(Some(2)), result_2); // may get: Some(2)
44+
Ok(())
45+
}
4746

48-
#[pg_test]
49-
#[search_path(@extschema@)]
50-
fn plrust_call_me() -> spi::Result<()> {
51-
let definition = r#"
47+
#[pg_test]
48+
#[search_path(@extschema@)]
49+
fn plrust_call_me() -> spi::Result<()> {
50+
let definition = r#"
5251
CREATE FUNCTION pick_ret(a int, b int, pick int)
5352
RETURNS int AS
5453
$$
@@ -59,22 +58,22 @@ fn plrust_call_me() -> spi::Result<()> {
5958
})
6059
$$ LANGUAGE plrust;
6160
"#;
62-
Spi::run(definition)?;
63-
let result_a = Spi::get_one::<i32>("SELECT pick_ret(3, 4, 0);");
64-
let result_b = Spi::get_one::<i32>("SELECT pick_ret(5, 6, 1);");
65-
let result_c = Spi::get_one::<i32>("SELECT pick_ret(7, 8, 2);");
66-
let result_z = Spi::get_one::<i32>("SELECT pick_ret(9, 99, -1);");
67-
assert_eq!(Ok(Some(3)), result_a); // may get: Some(4) or None
68-
assert_eq!(Ok(Some(6)), result_b); // may get: None
69-
assert_eq!(Ok(None), result_c);
70-
assert_eq!(Ok(None), result_z);
71-
Ok(())
72-
}
61+
Spi::run(definition)?;
62+
let result_a = Spi::get_one::<i32>("SELECT pick_ret(3, 4, 0);");
63+
let result_b = Spi::get_one::<i32>("SELECT pick_ret(5, 6, 1);");
64+
let result_c = Spi::get_one::<i32>("SELECT pick_ret(7, 8, 2);");
65+
let result_z = Spi::get_one::<i32>("SELECT pick_ret(9, 99, -1);");
66+
assert_eq!(Ok(Some(3)), result_a); // may get: Some(4) or None
67+
assert_eq!(Ok(Some(6)), result_b); // may get: None
68+
assert_eq!(Ok(None), result_c);
69+
assert_eq!(Ok(None), result_z);
70+
Ok(())
71+
}
7372

74-
#[pg_test]
75-
#[search_path(@extschema@)]
76-
fn plrust_call_me_call_me() -> spi::Result<()> {
77-
let definition = r#"
73+
#[pg_test]
74+
#[search_path(@extschema@)]
75+
fn plrust_call_me_call_me() -> spi::Result<()> {
76+
let definition = r#"
7877
CREATE FUNCTION ret_1st(a int, b int)
7978
RETURNS int AS
8079
$$
@@ -97,19 +96,19 @@ fn plrust_call_me_call_me() -> spi::Result<()> {
9796
})
9897
$$ LANGUAGE plrust;
9998
"#;
100-
Spi::run(definition)?;
101-
let result_1 = Spi::get_one::<i32>("SELECT ret_1st(1, 2);\n");
102-
let result_2 = Spi::get_one::<i32>("SELECT ret_2nd(1, 2);\n");
103-
let result_a = Spi::get_one::<i32>("SELECT pick_ret(3, 4, 0);");
104-
let result_b = Spi::get_one::<i32>("SELECT pick_ret(5, 6, 1);");
105-
let result_c = Spi::get_one::<i32>("SELECT pick_ret(7, 8, 2);");
106-
let result_z = Spi::get_one::<i32>("SELECT pick_ret(9, 99, -1);");
107-
assert_eq!(Ok(None), result_z);
108-
assert_eq!(Ok(None), result_c);
109-
assert_eq!(Ok(Some(6)), result_b); // may get: None
110-
assert_eq!(Ok(Some(3)), result_a); // may get: Some(4) or None
111-
assert_eq!(Ok(Some(2)), result_2); // may get: Some(1)
112-
assert_eq!(Ok(Some(1)), result_1); // may get: Some(2)
113-
Ok(())
99+
Spi::run(definition)?;
100+
let result_1 = Spi::get_one::<i32>("SELECT ret_1st(1, 2);\n");
101+
let result_2 = Spi::get_one::<i32>("SELECT ret_2nd(1, 2);\n");
102+
let result_a = Spi::get_one::<i32>("SELECT pick_ret(3, 4, 0);");
103+
let result_b = Spi::get_one::<i32>("SELECT pick_ret(5, 6, 1);");
104+
let result_c = Spi::get_one::<i32>("SELECT pick_ret(7, 8, 2);");
105+
let result_z = Spi::get_one::<i32>("SELECT pick_ret(9, 99, -1);");
106+
assert_eq!(Ok(None), result_z);
107+
assert_eq!(Ok(None), result_c);
108+
assert_eq!(Ok(Some(6)), result_b); // may get: None
109+
assert_eq!(Ok(Some(3)), result_a); // may get: Some(4) or None
110+
assert_eq!(Ok(Some(2)), result_2); // may get: Some(1)
111+
assert_eq!(Ok(Some(1)), result_1); // may get: Some(2)
112+
Ok(())
113+
}
114114
}
115-
}

plrust-tests/src/panics.rs

+17-18
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
/*
32
Portions Copyright 2020-2021 ZomboDB, LLC.
43
Portions Copyright 2021-2023 Technology Concepts & Design, Inc. <[email protected]>
@@ -11,20 +10,20 @@ Use of this source code is governed by the PostgreSQL license that can be found
1110
#[cfg(any(test, feature = "pg_test"))]
1211
#[pgrx::pg_schema]
1312
mod tests {
14-
use pgrx:: prelude::*;
13+
use pgrx::prelude::*;
1514

1615
#[pg_test]
17-
#[search_path(@extschema@)]
18-
#[should_panic = "yup"]
19-
fn pgrx_can_panic() {
20-
panic!("yup")
21-
}
16+
#[search_path(@extschema@)]
17+
#[should_panic = "yup"]
18+
fn pgrx_can_panic() {
19+
panic!("yup")
20+
}
2221

23-
#[pg_test]
24-
#[search_path(@extschema@)]
25-
#[should_panic = "yup"]
26-
fn plrust_can_panic() -> spi::Result<()> {
27-
let definition = r#"
22+
#[pg_test]
23+
#[search_path(@extschema@)]
24+
#[should_panic = "yup"]
25+
fn plrust_can_panic() -> spi::Result<()> {
26+
let definition = r#"
2827
CREATE FUNCTION shut_up_and_explode()
2928
RETURNS text AS
3029
$$
@@ -33,11 +32,11 @@ fn plrust_can_panic() -> spi::Result<()> {
3332
$$ LANGUAGE plrust;
3433
"#;
3534

36-
Spi::run(definition)?;
37-
let retval = Spi::get_one::<String>("SELECT shut_up_and_explode();\n");
38-
assert_eq!(retval, Ok(None));
39-
Ok(())
40-
}
35+
Spi::run(definition)?;
36+
let retval = Spi::get_one::<String>("SELECT shut_up_and_explode();\n");
37+
assert_eq!(retval, Ok(None));
38+
Ok(())
39+
}
4140
#[pg_test]
4241
#[search_path(@extschema@)]
4342
#[should_panic = "xxx"]
@@ -60,4 +59,4 @@ fn plrust_can_panic() -> spi::Result<()> {
6059
assert_eq!(retval, Ok(Some("lol".into())));
6160
Ok(())
6261
}
63-
}
62+
}

0 commit comments

Comments
 (0)