use assert_cmd::prelude::*;
use conserve::test_fixtures::ScratchArchive;
use indoc::indoc;
use predicates::function::function;
use predicates::prelude::*;
use crate::run_conserve;
#[test]
fn utc() {
run_conserve()
.args(["versions", "--utc", "testdata/archive/simple/v0.6.10"])
.assert()
.success()
.stdout(indoc! { "
b0000 2021-03-04T13:21:15Z 0:00
b0001 2021-03-04T13:21:30Z 0:00
b0002 2021-03-04T13:27:28Z 0:00
"});
}
#[test]
fn newest_first() {
run_conserve()
.args([
"versions",
"--newest",
"--utc",
"testdata/archive/simple/v0.6.10",
])
.assert()
.success()
.stderr(predicate::str::is_empty())
.stdout(indoc! { "
b0002 2021-03-04T13:27:28Z 0:00
b0001 2021-03-04T13:21:30Z 0:00
b0000 2021-03-04T13:21:15Z 0:00
"});
}
#[test]
fn local_time() {
run_conserve()
.args(["versions", "testdata/archive/simple/v0.6.10"])
.assert()
.success()
.stdout(function(|s: &str| s.lines().count() == 3));
}
#[test]
fn short() {
run_conserve()
.args(["versions", "--short", "testdata/archive/simple/v0.6.10"])
.assert()
.success()
.stdout(
"\
b0000
b0001
b0002
",
);
}
#[test]
fn tree_sizes() {
run_conserve()
.args([
"versions",
"--sizes",
"--utc",
"testdata/archive/simple/v0.6.10",
])
.assert()
.success()
.stdout(indoc! { "
b0000 2021-03-04T13:21:15Z 0:00 0 MB
b0001 2021-03-04T13:21:30Z 0:00 0 MB
b0002 2021-03-04T13:27:28Z 0:00 0 MB
"});
}
#[test]
fn short_newest_first() {
let af = ScratchArchive::new();
af.store_two_versions();
run_conserve()
.args(["versions", "--short", "--newest"])
.arg(af.path())
.assert()
.success()
.stderr(predicate::str::is_empty())
.stdout("b0001\nb0000\n");
}