Skip to content

Commit 74ce7bc

Browse files
Merge pull request #8 from geo-engine/natura2000
feat: mock process for natura2000 data
2 parents cb5d702 + 7a0aeab commit 74ce7bc

File tree

12 files changed

+609
-58
lines changed

12 files changed

+609
-58
lines changed

.github/workflows/ci.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,12 @@ jobs:
135135
- name: Start PostgreSQL
136136
run: |
137137
service postgresql start
138-
psql postgres://geoengine:geoengine@localhost -c "CREATE DATABASE biois;"
138+
sudo -u postgres psql << EOF
139+
\set AUTOCOMMIT on
140+
CREATE DATABASE biois OWNER geoengine;
141+
\c biois
142+
CREATE EXTENSION postgis;
143+
EOF
139144
- name: setup rust build cache
140145
uses: Swatinem/rust-cache@v2
141146
with:

backend/src/db/mod.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ pub async fn setup_db(config: &crate::config::Database) -> Result<DbPool> {
4545
let db_pool_builder = if cfg!(test) {
4646
db_pool_builder
4747
.max_size(1) // Use a single connection for tests
48-
.connection_customizer(Box::new(TestCustomizer))
48+
.connection_customizer(Box::new(TestCustomizer {
49+
schema: config.schema.clone(),
50+
}))
4951
} else {
5052
db_pool_builder
5153
.max_size(8) // TODO: investigate a good size
@@ -107,7 +109,7 @@ impl CustomizeConnection<AsyncPgConnection, PoolError> for SchemaSettingConnecti
107109
) -> Pin<Box<dyn Future<Output = Result<(), PoolError>> + Send + 'a>> {
108110
let schema = self.schema.clone();
109111
Box::pin(async move {
110-
conn.batch_execute(&format!("SET search_path TO {schema};"))
112+
conn.batch_execute(&format!("SET search_path TO {schema},public;"))
111113
.await
112114
.map_err(PoolError::QueryError)
113115
})
@@ -120,14 +122,21 @@ impl CustomizeConnection<AsyncPgConnection, PoolError> for SchemaSettingConnecti
120122
///
121123
/// Built after [`diesel::r2d2::TestCustomizer`]
122124
#[derive(Debug)]
123-
struct TestCustomizer;
125+
struct TestCustomizer {
126+
schema: String,
127+
}
124128

125129
impl CustomizeConnection<AsyncPgConnection, PoolError> for TestCustomizer {
126130
fn on_acquire<'a>(
127131
&'a self,
128132
conn: &'a mut AsyncPgConnection,
129133
) -> Pin<Box<dyn Future<Output = Result<(), PoolError>> + Send + 'a>> {
134+
let schema = self.schema.clone();
130135
Box::pin(async move {
136+
conn.batch_execute(&format!("SET search_path TO {schema},public;"))
137+
.await
138+
.map_err(PoolError::QueryError)?;
139+
131140
conn.begin_test_transaction()
132141
.await
133142
.map_err(PoolError::QueryError)

0 commit comments

Comments
 (0)