Use DATABASE_URL env variable for relational_tests

This commit is contained in:
Sam Samai 2021-07-31 16:03:29 +10:00
parent b2ed13868e
commit c240ebba77
2 changed files with 163 additions and 140 deletions

View File

@ -4,6 +4,7 @@ on:
push:
branches:
- master
- origin/ss/test_suite_refactor
pull_request:
branches:
- master
@ -50,95 +51,95 @@ jobs:
--all
--features default,runtime-${{ matrix.runtime }}
sqlite:
name: SQLite
runs-on: ubuntu-20.04
strategy:
matrix:
# runtime: [async-std-native-tls, async-std-rustls, actix-native-tls, actix-rustls, tokio-native-tls, tokio-rustls]
runtime: [async-std-native-tls]
steps:
- uses: actions/checkout@v2
# sqlite:
# name: SQLite
# runs-on: ubuntu-20.04
# strategy:
# matrix:
# # runtime: [async-std-native-tls, async-std-rustls, actix-native-tls, actix-rustls, tokio-native-tls, tokio-rustls]
# runtime: [async-std-native-tls]
# steps:
# - uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
# - uses: actions-rs/toolchain@v1
# with:
# profile: minimal
# toolchain: stable
# override: true
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-sqlite-${{ matrix.runtime }}-${{ hashFiles('**/Cargo.lock') }}
# - uses: actions/cache@v2
# with:
# path: |
# ~/.cargo/registry
# ~/.cargo/git
# target
# key: ${{ runner.os }}-sqlite-${{ matrix.runtime }}-${{ hashFiles('**/Cargo.lock') }}
- uses: actions-rs/cargo@v1
with:
command: build
args: >
--all
--features default,runtime-${{ matrix.runtime }}
# - uses: actions-rs/cargo@v1
# with:
# command: build
# args: >
# --all
# --features default,runtime-${{ matrix.runtime }}
- uses: actions-rs/cargo@v1
with:
command: test
args: >
--all
--features default,sqlx-sqlite,runtime-${{ matrix.runtime }}
# - uses: actions-rs/cargo@v1
# with:
# command: test
# args: >
# --all
# --features default,sqlx-sqlite,runtime-${{ matrix.runtime }}
postgres:
name: Postgres
runs-on: ubuntu-20.04
strategy:
matrix:
# runtime: [async-std-native-tls, async-std-rustls, actix-native-tls, actix-rustls, tokio-native-tls, tokio-rustls]
runtime: [async-std-native-tls]
services:
postgres:
image: postgres:11
env:
POSTGRES_HOST: 127.0.0.1
POSTGRES_USER: root
POSTGRES_PASSWORD: root
ports:
- "5432:5432"
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v2
# postgres:
# name: Postgres
# runs-on: ubuntu-20.04
# strategy:
# matrix:
# # runtime: [async-std-native-tls, async-std-rustls, actix-native-tls, actix-rustls, tokio-native-tls, tokio-rustls]
# runtime: [async-std-native-tls]
# services:
# postgres:
# image: postgres:11
# env:
# POSTGRES_HOST: 127.0.0.1
# POSTGRES_USER: root
# POSTGRES_PASSWORD: root
# ports:
# - "5432:5432"
# options: >-
# --health-cmd pg_isready
# --health-interval 10s
# --health-timeout 5s
# --health-retries 5
# steps:
# - uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
# - uses: actions-rs/toolchain@v1
# with:
# profile: minimal
# toolchain: stable
# override: true
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-postgres-${{ matrix.runtime }}-${{ hashFiles('**/Cargo.lock') }}
# - uses: actions/cache@v2
# with:
# path: |
# ~/.cargo/registry
# ~/.cargo/git
# target
# key: ${{ runner.os }}-postgres-${{ matrix.runtime }}-${{ hashFiles('**/Cargo.lock') }}
- uses: actions-rs/cargo@v1
with:
command: build
args: >
--all
--features default,runtime-${{ matrix.runtime }}
# - uses: actions-rs/cargo@v1
# with:
# command: build
# args: >
# --all
# --features default,runtime-${{ matrix.runtime }}
- uses: actions-rs/cargo@v1
with:
command: test
args: >
--all
--features default,sqlx-postgres,runtime-${{ matrix.runtime }}
# - uses: actions-rs/cargo@v1
# with:
# command: test
# args: >
# --all
# --features default,sqlx-postgres,runtime-${{ matrix.runtime }}
mysql:
name: MySQL
@ -147,6 +148,8 @@ jobs:
matrix:
# runtime: [async-std-native-tls, async-std-rustls, actix-native-tls, actix-rustls, tokio-native-tls, tokio-rustls]
runtime: [async-std-native-tls]
env:
DATABASE_URL: mysql://root:@localhost
services:
mysql:
image: mysql:8.0
@ -195,57 +198,57 @@ jobs:
--all
--features default,sqlx-mysql,runtime-${{ matrix.runtime }}
mariadb:
name: MariaDB
runs-on: ubuntu-20.04
strategy:
matrix:
# runtime: [async-std-native-tls, async-std-rustls, actix-native-tls, actix-rustls, tokio-native-tls, tokio-rustls]
runtime: [async-std-native-tls]
services:
mysql:
image: mariadb:10.5
env:
MYSQL_HOST: 127.0.0.1
MYSQL_DB: mysql
MYSQL_USER: sea
MYSQL_PASSWORD: sea
MYSQL_ALLOW_EMPTY_PASSWORD: yes
MYSQL_ROOT_PASSWORD:
ports:
- "3306:3306"
options: >-
--health-cmd="mysqladmin ping"
--health-interval=10s
--health-timeout=5s
--health-retries=3
steps:
- uses: actions/checkout@v2
# mariadb:
# name: MariaDB
# runs-on: ubuntu-20.04
# strategy:
# matrix:
# # runtime: [async-std-native-tls, async-std-rustls, actix-native-tls, actix-rustls, tokio-native-tls, tokio-rustls]
# runtime: [async-std-native-tls]
# services:
# mysql:
# image: mariadb:10.5
# env:
# MYSQL_HOST: 127.0.0.1
# MYSQL_DB: mysql
# MYSQL_USER: sea
# MYSQL_PASSWORD: sea
# MYSQL_ALLOW_EMPTY_PASSWORD: yes
# MYSQL_ROOT_PASSWORD:
# ports:
# - "3306:3306"
# options: >-
# --health-cmd="mysqladmin ping"
# --health-interval=10s
# --health-timeout=5s
# --health-retries=3
# steps:
# - uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
# - uses: actions-rs/toolchain@v1
# with:
# profile: minimal
# toolchain: stable
# override: true
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-mariadb-${{ matrix.runtime }}-${{ hashFiles('**/Cargo.lock') }}
# - uses: actions/cache@v2
# with:
# path: |
# ~/.cargo/registry
# ~/.cargo/git
# target
# key: ${{ runner.os }}-mariadb-${{ matrix.runtime }}-${{ hashFiles('**/Cargo.lock') }}
- uses: actions-rs/cargo@v1
with:
command: build
args: >
--all
--features default,runtime-${{ matrix.runtime }}
# - uses: actions-rs/cargo@v1
# with:
# command: build
# args: >
# --all
# --features default,runtime-${{ matrix.runtime }}
- uses: actions-rs/cargo@v1
with:
command: test
args: >
--all
--features default,sqlx-mysql,runtime-${{ matrix.runtime }}
# - uses: actions-rs/cargo@v1
# with:
# command: test
# args: >
# --all
# --features default,sqlx-mysql,runtime-${{ matrix.runtime }}

View File

@ -9,9 +9,13 @@ pub mod common;
pub use common::{bakery_chain::*, setup::*, TestContext};
#[async_std::test]
#[cfg(feature = "sqlx-mysql")]
#[cfg(any(
feature = "sqlx-mysql",
feature = "sqlx-sqlite",
feature = "sqlx-postgres"
))]
pub async fn left_join() {
let ctx = TestContext::new("mysql://root:@localhost", "test_left_join").await;
let ctx = TestContext::new("test_left_join").await;
let bakery = bakery::ActiveModel {
name: Set("SeaSide Bakery".to_owned()),
@ -86,9 +90,13 @@ pub async fn left_join() {
}
#[async_std::test]
#[cfg(feature = "sqlx-mysql")]
#[cfg(any(
feature = "sqlx-mysql",
feature = "sqlx-sqlite",
feature = "sqlx-postgres"
))]
pub async fn right_join() {
let ctx = TestContext::new("mysql://root:@localhost", "test_right_join").await;
let ctx = TestContext::new("test_right_join").await;
let bakery = bakery::ActiveModel {
name: Set("SeaSide Bakery".to_owned()),
@ -167,9 +175,13 @@ pub async fn right_join() {
}
#[async_std::test]
#[cfg(feature = "sqlx-mysql")]
#[cfg(any(
feature = "sqlx-mysql",
feature = "sqlx-sqlite",
feature = "sqlx-postgres"
))]
pub async fn inner_join() {
let ctx = TestContext::new("mysql://root:@localhost", "test_inner_join").await;
let ctx = TestContext::new("test_inner_join").await;
let bakery = bakery::ActiveModel {
name: Set("SeaSide Bakery".to_owned()),
@ -252,9 +264,13 @@ pub async fn inner_join() {
}
#[async_std::test]
#[cfg(feature = "sqlx-mysql")]
#[cfg(any(
feature = "sqlx-mysql",
feature = "sqlx-sqlite",
feature = "sqlx-postgres"
))]
pub async fn group_by() {
let ctx = TestContext::new("mysql://root:@localhost", "test_group_by").await;
let ctx = TestContext::new("test_group_by").await;
let bakery = bakery::ActiveModel {
name: Set("SeaSide Bakery".to_owned()),
@ -352,10 +368,14 @@ pub async fn group_by() {
}
#[async_std::test]
#[cfg(feature = "sqlx-mysql")]
#[cfg(any(
feature = "sqlx-mysql",
feature = "sqlx-sqlite",
feature = "sqlx-postgres"
))]
pub async fn having() {
// customers with orders with total equal to $90
let ctx = TestContext::new("mysql://root:@localhost", "test_having").await;
let ctx = TestContext::new("test_having").await;
let bakery = bakery::ActiveModel {
name: Set("SeaSide Bakery".to_owned()),