~glyph/myka

6b50c8232c26b94ee53e55741aab935a410c55d3 — mycognosist 4 months ago 0e8467c
Revert "Add integration tests for add, delete and list when culture doesn't exist"

This reverts commit 0e8467c0583caa9939cf319238c418eb7ae08c58.
4 files changed, 4 insertions(+), 162 deletions(-)

M Cargo.lock
M Cargo.toml
M src/lib.rs
D tests/cli.rs
M Cargo.lock => Cargo.lock +0 -101
@@ 22,18 22,6 @@ version = "1.0.28"
source = "registry+https://github.com/rust-lang/crates.io-index"

[[package]]
name = "assert_cmd"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
 "doc-comment 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
 "predicates 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
 "predicates-core 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
 "predicates-tree 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
 "wait-timeout 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "atty"
version = "0.2.13"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 43,11 31,6 @@ dependencies = [
]

[[package]]
name = "autocfg"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"

[[package]]
name = "backtrace"
version = "0.3.37"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 122,16 105,6 @@ dependencies = [
]

[[package]]
name = "difference"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"

[[package]]
name = "doc-comment"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"

[[package]]
name = "dotenv"
version = "0.14.1"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 162,14 135,6 @@ dependencies = [
]

[[package]]
name = "float-cmp"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
 "num-traits 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "heck"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 206,58 171,17 @@ name = "myka"
version = "0.1.1"
dependencies = [
 "anyhow 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)",
 "assert_cmd 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
 "diesel 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
 "dotenv 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)",
 "predicates 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
 "structopt 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "normalize-line-endings"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"

[[package]]
name = "num-traits"
version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
 "autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "pkg-config"
version = "0.3.16"
source = "registry+https://github.com/rust-lang/crates.io-index"

[[package]]
name = "predicates"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
 "difference 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
 "float-cmp 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
 "normalize-line-endings 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
 "predicates-core 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
 "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "predicates-core"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"

[[package]]
name = "predicates-tree"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
 "predicates-core 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
 "treeline 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "proc-macro2"
version = "0.4.30"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 357,11 281,6 @@ dependencies = [
]

[[package]]
name = "treeline"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"

[[package]]
name = "unicode-segmentation"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 387,14 306,6 @@ version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"

[[package]]
name = "wait-timeout"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
 "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "winapi"
version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 417,9 328,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "58fb5e95d83b38284460a5fda7d6470aa0b8844d283a0b614b8535e880800d2d"
"checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b"
"checksum anyhow 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)" = "d9a60d744a80c30fcb657dfe2c1b22bcb3e814c1a1e3674f32bf5820b570fbff"
"checksum assert_cmd 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c88b9ca26f9c16ec830350d309397e74ee9abdfd8eb1f71cb6ecc71a3fc818da"
"checksum atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "1803c647a3ec87095e7ae7acfca019e98de5ec9a7d01343f611cf3152ed71a90"
"checksum autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d"
"checksum backtrace 0.3.37 (registry+https://github.com/rust-lang/crates.io-index)" = "5180c5a20655b14a819b652fd2378fa5f1697b6c9ddad3e695c2f9cedf6df4e2"
"checksum backtrace-sys 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)" = "82a830b4ef2d1124a711c71d263c5abdc710ef8e907bd508c88be475cebc422b"
"checksum bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3d155346769a6855b86399e9bc3814ab343cd3d62c7e985113d46a0ec3c281fd"


@@ 429,23 338,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9"
"checksum diesel 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8d24935ba50c4a8dc375a0fd1f8a2ba6bdbdc4125713126a74b965d6a01a06d7"
"checksum diesel_derives 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "62a27666098617d52c487a41f70de23d44a1dc1f3aa5877ceba2790fb1f1cab4"
"checksum difference 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198"
"checksum doc-comment 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10"
"checksum dotenv 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4424bad868b0ffe6ae351ee463526ba625bbca817978293bbe6bb7dc1804a175"
"checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2"
"checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1"
"checksum float-cmp 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "da62c4f1b81918835a8c6a484a397775fff5953fe83529afd51b05f5c6a6617d"
"checksum heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205"
"checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
"checksum libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)" = "d44e80633f007889c7eff624b709ab43c92d708caad982295768a7b13ca3b5eb"
"checksum libsqlite3-sys 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fd6457c70bbff456d9fe49deaba35ec47c3e598bf8d7950ff0575ceb7a8a6ad1"
"checksum memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "88579771288728879b57485cc7d6b07d648c9f0141eb955f8ab7f9d45394468e"
"checksum normalize-line-endings 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "61807f77802ff30975e01f4f071c8ba10c022052f98b3294119f3e615d13e5be"
"checksum num-traits 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "c62be47e61d1842b9170f0fdeec8eba98e60e90e5446449a0545e5152acd7096"
"checksum pkg-config 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)" = "72d5370d90f49f70bd033c3d75e87fc529fbfff9d6f7cccef07d6170079d91ea"
"checksum predicates 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "347a1b6f0b21e636bc9872fb60b83b8e185f6f5516298b8238699f7f9a531030"
"checksum predicates-core 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "06075c3a3e92559ff8929e7a280684489ea27fe44805174c3ebd9328dcb37178"
"checksum predicates-tree 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8e63c4859013b38a76eca2414c64911fba30def9e3202ac461a2d22831220124"
"checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759"
"checksum quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1"
"checksum regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dc220bd33bdce8f093101afe22a037b8eb0e5af33592e6a9caafff0d4cb81cbd"


@@ 458,13 359,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "02353edf96d6e4dc81aea2d8490a7e9db177bf8acb0e951c24940bf866cb313f"
"checksum textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060"
"checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b"
"checksum treeline 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a7f741b240f1a48843f9b8e0444fb55fb2a4ff67293b50a9179dfd5ea67f8d41"
"checksum unicode-segmentation 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1967f4cdfc355b37fd76d2a954fb2ed3871034eb4f26d60537d88795cfc332a9"
"checksum unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "882386231c45df4700b275c7ff55b6f3698780a650026380e72dabe76fa46526"
"checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc"
"checksum vcpkg 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "33dd455d0f96e90a75803cfeb7f948768c08d70a6de9a8d2362461935698bf95"
"checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a"
"checksum wait-timeout 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9f200f5b12eb75f8c1ed65abd4b2db8a6e1b138a20de009dacee265a2498f3f6"
"checksum winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f10e386af2b13e47c89e7236a7a14a086791a2b88ebad6df9bf42040195cf770"
"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"

M Cargo.toml => Cargo.toml +0 -4
@@ 9,7 9,3 @@ structopt = "0.2.10"
diesel = { version = "1.4", features = ["sqlite"]  }
dotenv = "0.14"
anyhow = "1.0"

[dev-dependencies]
assert_cmd = "1"
predicates = "1"

M src/lib.rs => src/lib.rs +4 -3
@@ 35,6 35,7 @@ pub fn add_culture<'a>(
/// Delete a culture from the library.
pub fn delete_culture(unique_id: String) -> Result<usize> {
    use schema::cultures::dsl::*;
    //use schema::cultures;

    let conn = establish_connection()?;



@@ 102,7 103,7 @@ pub fn establish_connection() -> Result<SqliteConnection> {
}

#[test]
fn display_cultures() {
fn test_write_cultures() {
    let culture = Culture {
        id: 1,
        genus: "Hericium".to_string(),


@@ 114,9 115,9 @@ fn display_cultures() {
    let mut cultures = Vec::new();
    cultures.push(culture);
    let mut result = Vec::new();
    write_cultures(cultures, &mut result).unwrap();
    write_cultures(cultures, &mut result);
    assert_eq!(
        // Convert result `[u8; 52]` to a str to avoid `LengthAtMost32` error
        // convert result `[u8; 52]` to a str to avoid `LengthAtMost32` error
        std::str::from_utf8(&result).unwrap(),
        "HEUKWG001 Hericium erinaceus 'UK' (WoodlandGourmet)\n"
    );

D tests/cli.rs => tests/cli.rs +0 -54
@@ 1,54 0,0 @@
use assert_cmd::prelude::*; // Add methods on commands
use predicates::prelude::*; // Used for writing assertions
use std::error::Error;
use std::process::Command; // Run programs

#[test]
// Ensure nothing is printed to stdout when culture doesn't exist
fn culture_doesnt_exist() -> Result<(), Box<dyn Error>> {
    let mut cmd = Command::cargo_bin("myka")?;
    cmd.arg("list").arg("AAAAAA001");
    cmd.assert().success().stdout(predicate::str::contains(""));

    Ok(())
}

#[test]
// Ensure new culture is added and deleted successfully
fn culture_add_del_success() -> Result<(), Box<dyn Error>> {
    let mut add_cmd = Command::cargo_bin("myka")?;
    add_cmd
        .arg("add")
        .arg("Pleurotus")
        .arg("eryngii")
        .arg("M 2600")
        .arg("MyceliaBE")
        .arg("PE26MY001");
    add_cmd
        .assert()
        .success()
        .stdout(predicate::str::contains(""));

    let mut del_cmd = Command::cargo_bin("myka")?;
    del_cmd.arg("delete").arg("PE26MY001");
    del_cmd
        .assert()
        .success()
        .stdout(predicate::str::contains(""));

    Ok(())
}

/*
 * Database locks when add and delete tests are run separately
 *
#[test]
// Ensure new culture is deleted successfully
fn culture_delete_success() -> Result<(), Box<dyn Error>> {
    let mut cmd = Command::cargo_bin("myka")?;
    cmd.arg("delete").arg("PE26MY001");
    cmd.assert().success().stdout(predicate::str::contains(""));

    Ok(())
}
*/