Skip to content

Commit

Permalink
chore: add postgres tests to CI
Browse files Browse the repository at this point in the history
  • Loading branch information
nlopes committed Sep 10, 2023
1 parent be87051 commit 2ed5396
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 17 deletions.
19 changes: 18 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
strategy:
fail-fast: false
matrix:
postgresql-version = [15]
toolchain: [ 'stable' ]
nightly: [false]
include:
Expand All @@ -37,6 +38,14 @@ jobs:
rustup run ${{ matrix.toolchain }} cargo --version --verbose
rustup run ${{ matrix.toolchain }} cargo clippy --version
rustup run ${{ matrix.toolchain }} cargo fmt --version
- name: Install PostgreSQL client version matching docker-compose
env:
POSTGRESQL_VERSION: ${{ matrix.postgresql-version }}
run: |
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get -y install --no-install-recommends "postgresql-client-${POSTGRESQL_VERSION}"
- name: Cache cargo registry
uses: actions/cache@v3
Expand Down Expand Up @@ -67,11 +76,19 @@ jobs:
- name: Run test - mysql | sqlx | runtime-async-std
run: rustup run ${{ matrix.toolchain }} cargo test --features mysql,sqlx,runtime-async-std --all-targets --verbose

- name: Run test - postgres | diesel
run: rustup run ${{ matrix.toolchain }} cargo test --features postgres,diesel --all-targets --verbose

- name: Run test - postgres | sqlx | runtime-async-std
run: |
export PATH="/usr/lib/postgresql/${POSTGRESQL_VERSION}/bin:$PATH"
rustup run ${{ matrix.toolchain }} cargo test --features postgres,sqlx,runtime-async-std --all-targets --verbose
- name: Stop containers for database tests
if: always()
run: |
docker compose -f "docker-compose.yml" down --volumes
sudo rm -rf .data/{postgresql-15,mysql-8}
sudo rm -rf .data/{postgresql-${POSTGRESQL_VERSION},mysql-8}
- name: Run doc tests
run: rustup run ${{ matrix.toolchain }} cargo test --features sqlite,sqlx,runtime-async-std,macros --doc --verbose
Expand Down
7 changes: 0 additions & 7 deletions fixtures/diesel/postgres/diesel-postgres-structure.sql
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
--
-- PostgreSQL database dump
--

-- Dumped from database version 15.2
-- Dumped by pg_dump version 15.4 (Homebrew)

SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
Expand Down
7 changes: 0 additions & 7 deletions fixtures/sqlx/postgres/sqlx-postgres-structure.sql
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
--
-- PostgreSQL database dump
--

-- Dumped from database version 15.2
-- Dumped by pg_dump version 15.4 (Homebrew)

SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
Expand Down
4 changes: 2 additions & 2 deletions src/postgres/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Implementation of the `postgres` feature
pub(crate) const DEFAULT_CONNECTION_URL: &str = "postgresql://root:@localhost:5432/postgres";
pub(crate) const DEFAULT_CONNECTION_URL: &str = "postgresql://root:@127.0.0.1:5432/postgres";

use crate::error::Error;

Expand Down Expand Up @@ -83,7 +83,7 @@ mod tests {
destination_filename.as_ref()
)))?;
let contents = std::fs::read_to_string(destination_path)?;
assert_eq!(contents, expected);
assert!(contents.contains(&expected));
Ok(())
}

Expand Down

0 comments on commit 2ed5396

Please sign in to comment.