File src/sub_commands.cpp changed (mode: 100644) (index 7bb942b..ef1fb1e) |
... |
... |
private: |
708 |
708 |
const std::vector<std::string> &/*args*/) override |
const std::vector<std::string> &/*args*/) override |
709 |
709 |
{ |
{ |
710 |
710 |
std::string ref, refName; |
std::string ref, refName; |
711 |
|
std::cin >> ref >> refName; |
|
|
711 |
|
if (!(std::cin >> ref)) { |
|
712 |
|
std::cerr << "Invalid input format: failed to read reference\n"; |
|
713 |
|
error(); |
|
714 |
|
return; |
|
715 |
|
} |
|
716 |
|
if (!(std::cin >> refName)) { |
|
717 |
|
std::cerr << "Invalid input format: failed to read reference " |
|
718 |
|
"name\n"; |
|
719 |
|
error(); |
|
720 |
|
return; |
|
721 |
|
} |
712 |
722 |
|
|
713 |
723 |
const std::unordered_map<std::string, std::string> files = |
const std::unordered_map<std::string, std::string> files = |
714 |
724 |
repo->listFiles(ref); |
repo->listFiles(ref); |
File tests/sub_commands.cpp changed (mode: 100644) (index 1fe853b..73ca3ad) |
... |
... |
TEST_CASE("New handles input gracefully", "[subcommands][new-subcommand]") |
440 |
440 |
BuildHistory bh(db); |
BuildHistory bh(db); |
441 |
441 |
StreamCapture coutCapture(std::cout), cerrCapture(std::cerr); |
StreamCapture coutCapture(std::cout), cerrCapture(std::cerr); |
442 |
442 |
|
|
|
443 |
|
SECTION("Empty input") |
|
444 |
|
{ |
|
445 |
|
StreamSubstitute cinSubst(std::cin, ""); |
|
446 |
|
CHECK(getCmd("new")->exec(getSettings(), bh, repo, "new", |
|
447 |
|
{}) == EXIT_FAILURE); |
|
448 |
|
} |
|
449 |
|
|
|
450 |
|
SECTION("No reference name") |
|
451 |
|
{ |
|
452 |
|
StreamSubstitute cinSubst(std::cin, |
|
453 |
|
"8e354da4df664b71e06c764feb29a20d64351a01\n"); |
|
454 |
|
CHECK(getCmd("new")->exec(getSettings(), bh, repo, "new", |
|
455 |
|
{}) == EXIT_FAILURE); |
|
456 |
|
} |
|
457 |
|
|
443 |
458 |
SECTION("Missing hashsum") |
SECTION("Missing hashsum") |
444 |
459 |
{ |
{ |
445 |
460 |
StreamSubstitute cinSubst(std::cin, |
StreamSubstitute cinSubst(std::cin, |