Handlers: implement export tags handler

This commit is contained in:
rr- 2016-03-16 19:11:11 +01:00
parent 84a8d14ae0
commit a3daa0f108
2 changed files with 32 additions and 5 deletions

View File

@ -7,21 +7,25 @@ ExportTagsHandler::ExportTagsHandler(std::ostream &output_stream)
{
}
bool ExportTagsHandler::relevant(const int streamno)
bool ExportTagsHandler::relevant(const int)
{
return false;
return true;
}
void ExportTagsHandler::list(const int streamno, const Tags &)
void ExportTagsHandler::list(const int streamno, const Tags &tags)
{
output_stream << "[Stream " << streamno << "]\n";
for (const auto tag : tags.get_all())
output_stream << tag.key << "=" << tag.value << "\n";
output_stream << "\n";
}
bool ExportTagsHandler::edit(const int streamno, Tags &)
bool ExportTagsHandler::edit(const int, Tags &)
{
return false;
}
bool ExportTagsHandler::done()
{
return true;
return false;
}

View File

@ -0,0 +1,23 @@
#include "tags_handlers/export_tags_handler.h"
#include "catch.h"
#include <sstream>
using namespace opustags;
TEST_CASE("export tags handler", "[tags_handlers]")
{
std::stringstream ss;
ExportTagsHandler handler(ss);
handler.list(1, {{{"a", "value1"}, {"b", "value2"}}});
handler.list(2, {{{"c", "value3"}, {"d", "value4"}}});
REQUIRE(ss.str() == R"([Stream 1]
a=value1
b=value2
[Stream 2]
c=value3
d=value4
)");
}