commit 0f6a51caa78d437eeeecf279fee285b2e49c090e
parent 892a28c56eab76f73578e04f8ae66006862f77ac
Author: cfillion <cfillion@users.noreply.github.com>
Date: Fri, 6 Oct 2017 02:52:16 -0400
receipt: fix missing newline when updating through >1 versions [#21]
Diffstat:
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/receipt.cpp b/src/receipt.cpp
@@ -120,7 +120,7 @@ ostream &operator<<(ostream &os, const InstallTicket &t)
if(os.tellp() > 0)
os << "\r\n";
- os << t.m_version->package()->fullName() << "\r\n";
+ os << t.m_version->package()->fullName();
if(t.m_isUpdate) {
const auto &versions = t.m_version->package()->versions();
@@ -129,7 +129,7 @@ ostream &operator<<(ostream &os, const InstallTicket &t)
if(ver->name() <= t.m_previous)
break;
else if(ver->name() <= t.m_version->name())
- os << *ver;
+ os << "\r\n" << *ver;
}
}
else
diff --git a/test/receipt.cpp b/test/receipt.cpp
@@ -5,6 +5,7 @@
#include <index.hpp>
using Catch::Matchers::Contains;
+using Catch::Matchers::EndsWith;
using namespace std;
@@ -174,7 +175,8 @@ TEST_CASE("format install ticket", M) {
entry.version = VersionName("1.0");
stream << InstallTicket{v3, entry};
REQUIRE_THAT(stream.str(),
- !Contains("v1.0") && Contains("v2.0") && Contains("v3.0"));
+ !Contains("v1.0") && Contains("\r\nv3.0\r\n No changelog\r\nv2.0"));
+ REQUIRE_THAT(stream.str(), !EndsWith("\r\n"));
}
SECTION("downgrade") {