Skip to content

Commit

Permalink
[TEST] Adding cli tests for detect_breakends.
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon Sasse committed Oct 19, 2020
1 parent 95cf409 commit 2e07110
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 0 deletions.
4 changes: 4 additions & 0 deletions test/cli/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,9 @@ add_cli_test(find_deletions_cli_test.cpp)
add_dependencies (find_deletions_cli_test "find_deletions")
target_use_datasources (find_deletions_cli_test FILES detect_breakends_shorted.vcf)

add_cli_test(detect_breakends_cli_test.cpp)
add_dependencies (detect_breakends_cli_test "detect_breakends")
target_use_datasources (detect_breakends_cli_test FILES converted_bam_shorted.sam)

# add_cli_test (iGenVar_options_test.cpp)
# target_use_datasources (iGenVar_options_test FILES in.fastq)
70 changes: 70 additions & 0 deletions test/cli/detect_breakends_cli_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#include <seqan3/alphabet/nucleotide/dna5.hpp>
#include <seqan3/io/sequence_file/input.hpp>

#include "cli_test.hpp"
#include <fstream>
#include <sstream>
TEST_F(cli_test, no_options)
{
cli_test_result result = execute_app("detect_breakends");
std::string expected
{
"detectJunctions - Detect junctions in a read alignment file\n"
"===========================================================\n"
" Try -h or --help for more information.\n"
};
EXPECT_EQ(result.exit_code, 0);
EXPECT_EQ(result.out, expected);
EXPECT_EQ(result.err, std::string{});
}

TEST_F(cli_test, fail_no_argument)
{
cli_test_result result = execute_app("detect_breakends", "-v");
std::string expected
{
"[Error] Unknown option -v. In case this is meant to be a non-option/argument/parameter, please specify "
"the start of non-options with '--'. See -h/--help for program information.\n"
};
EXPECT_NE(result.exit_code, 0);
EXPECT_EQ(result.out, std::string{});
EXPECT_EQ(result.err, expected);
}


TEST_F(cli_test, with_arguments)
{
cli_test_result result = execute_app("detect_breakends",
data("converted_bam_shorted.sam"),
"detect_breakends_insertion_file_out.fasta");
std::string expected
{
"Reference\tchr9\t70103073\tForward\tReference\tchr9\t70103147\tForward\tm13802/6999/CCS\n"
};
std::string expected_err
{
"DEL: Reference\tchr9\t70103073\tForward\tReference\tchr9\t70103147\tForward\tm13802/6999/CCS\nDone. Found 1 junctions.\n"
};
EXPECT_EQ(result.exit_code, 0);
EXPECT_EQ(result.out, expected);
EXPECT_EQ(result.err, expected_err);
}

TEST_F(cli_test, test_outfile)
{
cli_test_result result = execute_app("detect_breakends",
data("converted_bam_shorted.sam"),
"detect_breakends_insertion_file_out.fasta");
std::ifstream f;
f.open("detect_breakends_insertion_file_out.fasta");
std::stringstream buffer;
buffer << f.rdbuf();
//expected string currently empty:
std::string expected
{
""
};
//this does not specifically check if file exists, rather if its readable.
EXPECT_TRUE(f.is_open());
EXPECT_EQ(buffer.str(), expected);
}

0 comments on commit 2e07110

Please sign in to comment.