use crate::utils::{EmbedExt, TestResources, diff::diff, setup};
use clap::Parser;
use portable_network_archive::{cli, command::Command};

#[test]
fn archive_strip_metadata() {
    setup();
    TestResources::extract_in("raw/", "archive_strip_metadata/in/").unwrap();
    cli::Cli::try_parse_from([
        "pna",
        "--quiet",
        "c",
        "archive_strip_metadata/strip_metadata.pna",
        "--overwrite",
        "archive_strip_metadata/in/",
        "--keep-xattr",
        "--keep-timestamp",
        "--keep-permission",
        #[cfg(windows)]
        "--unstable",
    ])
    .unwrap()
    .execute()
    .unwrap();
    cli::Cli::try_parse_from([
        "pna",
        "--quiet",
        "strip",
        "archive_strip_metadata/strip_metadata.pna",
        "--keep-xattr",
        "--keep-timestamp",
        "--keep-permission",
        #[cfg(windows)]
        "--unstable",
    ])
    .unwrap()
    .execute()
    .unwrap();
    cli::Cli::try_parse_from([
        "pna",
        "--quiet",
        "x",
        "archive_strip_metadata/strip_metadata.pna",
        "--overwrite",
        "--out-dir",
        "archive_strip_metadata/out/",
        "--keep-xattr",
        "--keep-timestamp",
        "--keep-permission",
        "--strip-components",
        "2",
        #[cfg(windows)]
        "--unstable",
    ])
    .unwrap()
    .execute()
    .unwrap();

    diff("archive_strip_metadata/in/", "archive_strip_metadata/out/").unwrap();
}
