use gosh_core::*;
use gosh_database::prelude::*;
use gosh_database::DbConnection;
use gut::prelude::*;
#[derive(Clone, Debug, Serialize, Deserialize)]
struct Test {
data: f64,
}
#[test]
fn test_checkpoint_and_collection() -> Result<()> {
let tdir = tempfile::tempdir()?;
let tmpdb = tdir.path().join("test.sqlite");
std::env::set_var("GOSH_DATABASE_URL", tmpdb);
let db = DbConnection::establish().unwrap();
let x = Test { data: -12.0 };
x.put_into_collection(&db, "test1")?;
x.commit_checkpoint(&db)?;
let mut x = Test { data: 12.0 };
x.restore_from_checkpoint(&db)?;
assert_eq!(x.data, -12.0);
Ok(())
}