Skip to content

Commit

Permalink
switch chrono for time fixes rust-db#191
Browse files Browse the repository at this point in the history
  • Loading branch information
jxs committed Dec 7, 2021
1 parent 52a6d2e commit 7bedda2
Show file tree
Hide file tree
Showing 20 changed files with 134 additions and 72 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
strategy:
matrix:
os: [windows-latest, ubuntu-latest]
rust: [stable, nightly, 1.55.0]
rust: [stable, nightly, 1.56.0]
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
Expand All @@ -45,7 +45,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
rust: [stable, nightly, 1.55.0]
rust: [stable, nightly, 1.56.0]
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
Expand All @@ -59,7 +59,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
rust: [stable, nightly, 1.55.0]
rust: [stable, nightly, 1.56.0]
services:
postgres:
image: postgres:9.6.13-alpine
Expand All @@ -78,7 +78,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
rust: [stable, nightly, 1.55.0]
rust: [stable, nightly, 1.56.0]
services:
postgres:
image: postgres:9.6.13-alpine
Expand All @@ -96,7 +96,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
rust: [stable, nightly, 1.55.0]
rust: [stable, nightly, 1.56.0]
services:
postgres:
image: mysql:latest
Expand All @@ -120,7 +120,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
rust: [stable, nightly, 1.55.0]
rust: [stable, nightly, 1.56.0]
services:
postgres:
image: mysql:latest
Expand All @@ -143,7 +143,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
rust: [stable, nightly, 1.55.0]
rust: [stable, nightly, 1.56.0]
services:
mssql:
image: mcr.microsoft.com/mssql/server:2017-latest
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased - 2021-10-16
### Changed
- replace `chrono` with `time`, fixes [191](https://github.com/rust-db/refinery/issues/191)

## [0.7.0] - 2021-10-16
### Added
- Add `Target::Fake` and `Target::FakeVersion` to allow users to only update refinery's schema migration table without actually running the migration files
Expand Down
2 changes: 1 addition & 1 deletion refinery/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ futures = "0.3"
assert_cmd = "2.0"
predicates = "2"
tempfile = "3"
chrono = "0.4"
time = "0.3.5"
tokio-util = { version = "0.6.7", features = ["compat"] }
tokio = { version = "1.9.0", features = ["full"] }
17 changes: 13 additions & 4 deletions refinery/tests/mysql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use barrel::backend::MySql as Sql;
#[cfg(feature = "mysql")]
mod mysql {
use assert_cmd::prelude::*;
use chrono::Local;
use mysql::prelude::TextQuery;
use predicates::str::contains;
use refinery::embed_migrations;
Expand All @@ -14,6 +13,7 @@ mod mysql {
};
use refinery_core::mysql;
use std::process::Command;
use time::OffsetDateTime;

mod embedded {
use refinery::embed_migrations;
Expand Down Expand Up @@ -210,7 +210,10 @@ mod mysql {
let current = conn.get_last_applied_migration().unwrap().unwrap();

assert_eq!(4, current.version());
assert_eq!(Local::today(), current.applied_on().unwrap().date());
assert_eq!(
OffsetDateTime::now_utc().date(),
current.applied_on().unwrap().date()
);
});
}

Expand All @@ -231,7 +234,10 @@ mod mysql {
let current = conn.get_last_applied_migration().unwrap().unwrap();

assert_eq!(4, current.version());
assert_eq!(Local::today(), current.applied_on().unwrap().date());
assert_eq!(
OffsetDateTime::now_utc().date(),
current.applied_on().unwrap().date()
);
});
}

Expand All @@ -253,7 +259,10 @@ mod mysql {
let migrations = get_migrations();
let applied_migrations = err.report().unwrap().applied_migrations();

assert_eq!(Local::today(), current.applied_on().unwrap().date());
assert_eq!(
OffsetDateTime::now_utc().date(),
current.applied_on().unwrap().date()
);
assert_eq!(2, current.version());
assert_eq!(2, applied_migrations.len());

Expand Down
17 changes: 13 additions & 4 deletions refinery/tests/mysql_async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use barrel::backend::MySql as Sql;

#[cfg(feature = "mysql_async")]
mod mysql_async {
use chrono::Local;
use futures::FutureExt;
use refinery::{
config::{Config, ConfigDbType},
Expand All @@ -13,6 +12,7 @@ mod mysql_async {
use refinery_core::mysql_async;
use refinery_core::mysql_async::prelude::Queryable;
use std::panic::AssertUnwindSafe;
use time::OffsetDateTime;

fn get_migrations() -> Vec<Migration> {
embed_migrations!("./tests/migrations");
Expand Down Expand Up @@ -237,7 +237,10 @@ mod mysql_async {
let current = pool.get_last_applied_migration().await.unwrap().unwrap();

assert_eq!(4, current.version());
assert_eq!(Local::today(), current.applied_on().unwrap().date());
assert_eq!(
OffsetDateTime::now_utc().date(),
current.applied_on().unwrap().date()
);
})
.await
}
Expand All @@ -257,7 +260,10 @@ mod mysql_async {
let current = pool.get_last_applied_migration().await.unwrap().unwrap();

assert_eq!(4, current.version());
assert_eq!(Local::today(), current.applied_on().unwrap().date());
assert_eq!(
OffsetDateTime::now_utc().date(),
current.applied_on().unwrap().date()
);
})
.await
}
Expand All @@ -276,7 +282,10 @@ mod mysql_async {
let migrations = get_migrations();
let applied_migrations = err.report().unwrap().applied_migrations();

assert_eq!(Local::today(), current.applied_on().unwrap().date());
assert_eq!(
OffsetDateTime::now_utc().date(),
current.applied_on().unwrap().date()
);
assert_eq!(2, current.version());
assert_eq!(2, applied_migrations.len());

Expand Down
16 changes: 12 additions & 4 deletions refinery/tests/postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use barrel::backend::Pg as Sql;
#[cfg(feature = "postgres")]
mod postgres {
use assert_cmd::prelude::*;
use chrono::Local;
use predicates::str::contains;
use refinery::{
config::{Config, ConfigDbType},
Expand Down Expand Up @@ -214,7 +213,10 @@ mod postgres {
let current = client.get_last_applied_migration().unwrap().unwrap();

assert_eq!(4, current.version());
assert_eq!(Local::today(), current.applied_on().unwrap().date());
assert_eq!(
OffsetDateTime::now_utc().date(),
current.applied_on().unwrap().date()
);
});
}

Expand All @@ -231,7 +233,10 @@ mod postgres {

let current = client.get_last_applied_migration().unwrap().unwrap();
assert_eq!(4, current.version());
assert_eq!(Local::today(), current.applied_on().unwrap().date());
assert_eq!(
OffsetDateTime::now_utc().date(),
current.applied_on().unwrap().date()
);
});
}

Expand All @@ -252,7 +257,10 @@ mod postgres {
let migrations = get_migrations();
let applied_migrations = err.report().unwrap().applied_migrations();

assert_eq!(Local::today(), current.applied_on().unwrap().date());
assert_eq!(
OffsetDateTime::now_utc().date(),
current.applied_on().unwrap().date()
);
assert_eq!(2, current.version());
assert_eq!(2, applied_migrations.len());

Expand Down
17 changes: 13 additions & 4 deletions refinery/tests/rusqlite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use barrel::backend::Sqlite as Sql;
#[cfg(feature = "rusqlite")]
mod rusqlite {
use assert_cmd::prelude::*;
use chrono::Local;
use predicates::str::contains;
use refinery::{
config::{Config, ConfigDbType},
Expand All @@ -15,6 +14,7 @@ mod rusqlite {
use refinery_core::rusqlite::{Connection, OptionalExtension};
use std::fs::{self, File};
use std::process::Command;
use time::OffsetDateTime;

mod embedded {
use refinery::embed_migrations;
Expand Down Expand Up @@ -188,7 +188,10 @@ mod rusqlite {

assert_eq!(4, current.version());

assert_eq!(Local::today(), current.applied_on().unwrap().date());
assert_eq!(
OffsetDateTime::now_utc().date(),
current.applied_on().unwrap().date()
);
}

#[test]
Expand All @@ -204,7 +207,10 @@ mod rusqlite {

assert_eq!(4, current.version());

assert_eq!(Local::today(), current.applied_on().unwrap().date());
assert_eq!(
OffsetDateTime::now_utc().date(),
current.applied_on().unwrap().date()
);
}

#[test]
Expand All @@ -220,7 +226,10 @@ mod rusqlite {
let migrations = get_migrations();
let applied_migrations = err.report().unwrap().applied_migrations();

assert_eq!(Local::today(), current.applied_on().unwrap().date());
assert_eq!(
OffsetDateTime::now_utc().date(),
current.applied_on().unwrap().date()
);
assert_eq!(2, current.version());
assert_eq!(2, applied_migrations.len());

Expand Down
17 changes: 13 additions & 4 deletions refinery/tests/tiberius.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use barrel::backend::MsSql as Sql;
#[cfg(all(feature = "tiberius-config"))]
mod tiberius {
use assert_cmd::prelude::*;
use chrono::Local;
use futures::FutureExt;
use predicates::str::contains;
use refinery::{
Expand All @@ -14,6 +13,7 @@ mod tiberius {
use std::panic::AssertUnwindSafe;
use std::process::Command;
use std::str::FromStr;
use time::OffsetDateTime;
use tokio_util::compat::TokioAsyncWriteCompatExt;

const CONFIG: &'static str = "mssql://SA:Passw0rd@localhost:1433/refinery_test?trust_cert=true";
Expand Down Expand Up @@ -512,7 +512,10 @@ mod tiberius {

let current = client.get_last_applied_migration().await.unwrap().unwrap();
assert_eq!(4, current.version());
assert_eq!(Local::today(), current.applied_on().unwrap().date());
assert_eq!(
OffsetDateTime::now_utc().date(),
current.applied_on().unwrap().date()
);
})
.await
}
Expand Down Expand Up @@ -543,7 +546,10 @@ mod tiberius {

let current = client.get_last_applied_migration().await.unwrap().unwrap();
assert_eq!(4, current.version());
assert_eq!(Local::today(), current.applied_on().unwrap().date());
assert_eq!(
OffsetDateTime::now_utc().date(),
current.applied_on().unwrap().date()
);
})
.await
}
Expand Down Expand Up @@ -574,7 +580,10 @@ mod tiberius {
let migrations = get_migrations();
let applied_migrations = err.report().unwrap().applied_migrations();

assert_eq!(Local::today(), current.applied_on().unwrap().date());
assert_eq!(
OffsetDateTime::now_utc().date(),
current.applied_on().unwrap().date()
);
assert_eq!(2, current.version());
assert_eq!(2, applied_migrations.len());

Expand Down
17 changes: 13 additions & 4 deletions refinery/tests/tokio_postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use barrel::backend::Pg as Sql;

#[cfg(feature = "tokio-postgres")]
mod tokio_postgres {
use chrono::Local;
use futures::FutureExt;
use refinery::{
config::{Config, ConfigDbType},
Expand All @@ -13,6 +12,7 @@ mod tokio_postgres {
use refinery_core::tokio_postgres;
use refinery_core::tokio_postgres::NoTls;
use std::panic::AssertUnwindSafe;
use time::OffsetDateTime;

fn get_migrations() -> Vec<Migration> {
embed_migrations!("./tests/migrations");
Expand Down Expand Up @@ -294,7 +294,10 @@ mod tokio_postgres {
let current = client.get_last_applied_migration().await.unwrap().unwrap();

assert_eq!(4, current.version());
assert_eq!(Local::today(), current.applied_on().unwrap().date());
assert_eq!(
OffsetDateTime::now_utc().date(),
current.applied_on().unwrap().date()
);
})
.await
}
Expand All @@ -320,7 +323,10 @@ mod tokio_postgres {
let current = client.get_last_applied_migration().await.unwrap().unwrap();

assert_eq!(4, current.version());
assert_eq!(Local::today(), current.applied_on().unwrap().date());
assert_eq!(
OffsetDateTime::now_utc().date(),
current.applied_on().unwrap().date()
);
})
.await
}
Expand All @@ -346,7 +352,10 @@ mod tokio_postgres {
let migrations = get_migrations();
let applied_migrations = err.report().unwrap().applied_migrations();

assert_eq!(Local::today(), current.applied_on().unwrap().date());
assert_eq!(
OffsetDateTime::now_utc().date(),
current.applied_on().unwrap().date()
);
assert_eq!(2, current.version());
assert_eq!(2, applied_migrations.len());

Expand Down

0 comments on commit 7bedda2

Please sign in to comment.