Skip to content
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
d53f1f5
Initial plan
Copilot Feb 11, 2026
1448693
Add test-pg feature and update PostgreSQL test gates
Copilot Feb 11, 2026
127895d
Update justfile and CI to use test-pg feature
Copilot Feb 11, 2026
338eb3f
Document test-pg feature in development guide
Copilot Feb 11, 2026
998fbbe
Update justfile
CommanderStorm Feb 11, 2026
7ae0f09
Fix justfile arg passing and gate builder tests with test-pg
Copilot Feb 11, 2026
8e7cb04
Add dedicated test-pg recipe to justfile
Copilot Feb 11, 2026
b9e39b0
Make test-pg run only PostgreSQL-specific tests
Copilot Feb 11, 2026
575aa77
Apply suggestion from @CommanderStorm
CommanderStorm Feb 11, 2026
218884e
Apply suggestion from @CommanderStorm
CommanderStorm Feb 11, 2026
2652a0a
Apply suggestion from @CommanderStorm
CommanderStorm Feb 11, 2026
263e091
Apply suggestion from @CommanderStorm
CommanderStorm Feb 11, 2026
5ce0aec
Apply suggestion from @CommanderStorm
CommanderStorm Feb 11, 2026
6b8f02f
Apply suggestions from code review
CommanderStorm Feb 11, 2026
23c6721
Apply suggestions from code review
CommanderStorm Feb 11, 2026
b5b49de
Apply suggestion from @CommanderStorm
CommanderStorm Feb 11, 2026
c2597d3
Apply suggestion from @CommanderStorm
CommanderStorm Feb 11, 2026
af9ce14
Merge branch 'main' into copilot/feature-gate-postgresql-tests
CommanderStorm Feb 11, 2026
31164bf
Apply suggestions from code review
CommanderStorm Feb 11, 2026
dc4241e
Apply suggestion from @CommanderStorm
CommanderStorm Feb 11, 2026
c84856b
add just to the postgis workflow
CommanderStorm Feb 11, 2026
0d7ebcb
Fix CI port conflict and improve docs formatting
Copilot Feb 12, 2026
461216a
Apply suggestion from @CommanderStorm
CommanderStorm Feb 12, 2026
cc6edf4
Apply suggestion from @CommanderStorm
CommanderStorm Feb 12, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ jobs:
- name: Checkout sources
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with: { persist-credentials: false }
- uses: taiki-e/install-action@763e3324d4fd026c9bd284c504378585777a87d5 # v2.62.57
with: { tool: 'just' }
- name: Init database
run: tests/fixtures/initdb.sh
env:
Expand All @@ -92,6 +94,7 @@ jobs:
cargo test --package mbtiles
cargo test --package martin
cargo test --package martin-core
just test-pg
env:
DATABASE_URL: postgres://${{ env.PGUSER }}:${{ env.PGUSER }}@${{ env.PGHOST }}:${{ job.services.postgres.ports[5432] }}/${{ env.PGDATABASE }}?sslmode=require
AWS_SKIP_CREDENTIALS: 1
Expand Down Expand Up @@ -665,6 +668,8 @@ jobs:
- name: Checkout sources
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with: { persist-credentials: false }
- uses: taiki-e/install-action@763e3324d4fd026c9bd284c504378585777a87d5 # v2.62.57
with: { tool: 'just' }
# cache for the unit-test to be run against postgres to be acceptably slow
- uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2
if: github.event_name != 'release' && github.event_name != 'workflow_dispatch'
Expand Down Expand Up @@ -738,6 +743,7 @@ jobs:
echo "$DATABASE_URL" | base64
set -x
cargo test --package martin
just test-pg
cargo clean
env:
DATABASE_URL: postgres://${{ env.PGUSER }}:${{ env.PGUSER }}@${{ env.PGHOST }}:${{ job.services.postgres.ports[5432] }}/${{ env.PGDATABASE }}?sslmode=${{ matrix.sslmode }}
Expand Down
17 changes: 17 additions & 0 deletions docs/src/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,23 @@
just stop # stop test database
```

### Testing

Martin's test suite includes tests that require PostgreSQL to be running and tests that don't.

```bash
# Run tests that don't require PostgreSQL (no external dependencies)
just test-cargo

# Run all tests including PostgreSQL tests (requires PostgreSQL running)
just test # runs all tests
just test-pg # starts PostgreSQL and runs only PostgreSQL-requiring tests
```

The `test-pg` feature gates tests that require a live PostgreSQL connection.
This allows developers to run most tests locally without setting up PostgreSQL, while CI and integration testing can enable these tests explicitly.
```

Check failure on line 161 in docs/src/development.md

View workflow job for this annotation

GitHub Actions / Build Docs

Fenced code blocks should have a language specified

docs/src/development.md:161 MD040/fenced-code-language Fenced code blocks should have a language specified [Context: "```"] https://github.com/DavidAnson/markdownlint/blob/v0.40.0/doc/md040.md

Check failure on line 161 in docs/src/development.md

View workflow job for this annotation

GitHub Actions / Build Docs

Fenced code blocks should be surrounded by blank lines

docs/src/development.md:161 MD031/blanks-around-fences Fenced code blocks should be surrounded by blank lines [Context: "```"] https://github.com/DavidAnson/markdownlint/blob/v0.40.0/doc/md031.md

### Pass arguments to commands

```bash
Expand Down
15 changes: 11 additions & 4 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ coverage *args='--no-clean --open': (cargo-install 'cargo-llvm-cov') clean star

echo "::group::Unit tests"
{{just}} test-cargo --all-targets
{{just}} test-pg
echo "::endgroup::"

# echo "::group::Documentation tests"
Expand Down Expand Up @@ -383,7 +384,13 @@ shear:
# https://github.com/Boshen/cargo-shear/pull/386

# Run all tests using a test database
test: start (test-cargo '--all-targets') test-doc test-frontend test-int
test: start (test-cargo "--all-targets") test-pg test-doc test-frontend test-int

# Run PostgreSQL-requiring tests only
test-pg: start
cargo test --features test-pg --test pg_function_source_test --test pg_server_test --test pg_table_source_test
cargo test --features test-pg --package martin --lib
cargo test --features test-pg --package martin-core --lib

# Run Rust unit tests (cargo test)
test-cargo *args:
Expand Down Expand Up @@ -473,10 +480,10 @@ test-lambda martin_bin='target/debug/martin':


# Run all tests using the oldest supported version of the database
test-legacy: start-legacy (test-cargo '--all-targets') test-doc test-int
test-legacy: start-legacy (test-cargo "--all-targets") test-pg test-doc test-int

# Run all tests using an SSL connection to a test database. Expected output won't match.
test-ssl: start-ssl (test-cargo '--all-targets') test-doc clean-test
test-ssl: start-ssl (test-cargo "--all-targets") test-pg test-doc clean-test
tests/test.sh

# Run all tests using an SSL connection with client cert to a test database. Expected output won't match.
Expand Down Expand Up @@ -602,7 +609,7 @@ docker-is-ready:

# Start a specific test database, e.g. db or db-legacy
[private]
docker-up name: start-pmtiles-server
docker-up name:
docker compose up -d {{name}}

# Install SQLX cli if not already installed.
Expand Down
1 change: 1 addition & 0 deletions martin-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ styles = ["tokio/fs", "dep:dashmap"]
mbtiles = ["dep:mbtiles", "_tiles"]
pmtiles = ["dep:pmtiles", "dep:object_store", "_tiles"]
_tiles = ["dep:base64"]
test-pg = ["postgres"]

[target.'cfg(target_os = "linux")'.dependencies]
image = { workspace = true, optional = true }
Expand Down
2 changes: 1 addition & 1 deletion martin-core/src/tiles/postgres/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ SELECT (regexp_matches(
Ok(version)
}

#[cfg(test)]
#[cfg(all(test, feature = "test-pg"))]
mod tests {
use deadpool_postgres::tokio_postgres::Config;
use postgres::NoTls;
Expand Down
1 change: 1 addition & 0 deletions martin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ sprites = ["martin-core/sprites"]
styles = ["martin-core/styles", "dep:walkdir"]
webui = ["dep:actix-web-static-files", "dep:static-files", "dep:walkdir"]
_tiles = ["martin-core/_tiles"]
test-pg = ["postgres"]

[dependencies]
actix-cors.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion martin/src/config/file/tiles/postgres/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ fn by_key<T>(a: &(String, T), b: &(String, T)) -> Ordering {
a.0.cmp(&b.0)
}

#[cfg(test)]
#[cfg(all(test, feature = "test-pg"))]
mod tests {
use indoc::indoc;
use insta::assert_yaml_snapshot;
Expand Down
2 changes: 1 addition & 1 deletion martin/tests/pg_function_source_test.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![cfg(feature = "postgres")]
#![cfg(feature = "test-pg")]

use indoc::indoc;
use insta::assert_yaml_snapshot;
Expand Down
2 changes: 1 addition & 1 deletion martin/tests/pg_server_test.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![cfg(feature = "postgres")]
#![cfg(feature = "test-pg")]

use actix_http::Request;
use actix_web::http::StatusCode;
Expand Down
2 changes: 1 addition & 1 deletion martin/tests/pg_table_source_test.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![cfg(feature = "postgres")]
#![cfg(feature = "test-pg")]

use indoc::indoc;
use insta::assert_yaml_snapshot;
Expand Down
6 changes: 3 additions & 3 deletions martin/tests/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::env;

use actix_web::dev::ServiceResponse;
use actix_web::test::read_body;
#[cfg(feature = "postgres")]
#[cfg(feature = "test-pg")]
use martin::config::file::postgres::TableInfo;
use martin::config::file::{Config, ServerState};
use martin::config::primitives::env::FauxEnv;
Expand Down Expand Up @@ -56,7 +56,7 @@ pub fn source(mock: &MockSource, name: &str) -> BoxedSource {
sources.tiles.get_source(name).expect("source can be found")
}

#[cfg(feature = "postgres")]
#[cfg(feature = "test-pg")]
#[must_use]
pub fn mock_pgcfg(yaml: &str) -> Config {
mock_cfg(&indoc::formatdoc! {"
Expand All @@ -65,7 +65,7 @@ pub fn mock_pgcfg(yaml: &str) -> Config {
", yaml.replace('\n', "\n ")})
}

#[cfg(feature = "postgres")]
#[cfg(feature = "test-pg")]
#[must_use]
pub fn table<'a>(mock: &'a MockSource, name: &str) -> &'a TableInfo {
let (_, config) = mock;
Expand Down
Loading