summaryrefslogtreecommitdiff
path: root/test/libapt
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2016-11-24 12:14:39 +0100
committerDavid Kalnischkies <david@kalnischkies.de>2016-11-25 00:15:13 +0100
commite1ae0531bfad0fce8590c26d1e38825df22d812a (patch)
tree54b648fe14a8d64778f2fc01050543a31f6c45f8 /test/libapt
parent0123ce7171b09ead5a07567fbd33c53f609f6560 (diff)
optional write aptwebserver log to client specific files
The test test-handle-redirect-as-used-mirror-change serves multiple clients at the same time, so the order of the output is undefined and once in a while the two clients will intermix their lines causing the grep we perform on it later to fail making our tests fail. Solved by introducing client-specific logfiles which we all grep and sort the result to have the results more stable. Git-Dch: Ignore
Diffstat (limited to 'test/libapt')
-rw-r--r--test/libapt/teestream_test.cc39
1 files changed, 39 insertions, 0 deletions
diff --git a/test/libapt/teestream_test.cc b/test/libapt/teestream_test.cc
new file mode 100644
index 000000000..18610b24d
--- /dev/null
+++ b/test/libapt/teestream_test.cc
@@ -0,0 +1,39 @@
+#include <config.h>
+
+#include <string>
+#include <sstream>
+#include <fstream>
+#include "../interactive-helper/teestream.h"
+
+#include <gtest/gtest.h>
+
+TEST(TeeStreamTest,TwoStringSinks)
+{
+ std::ostringstream one, two;
+ basic_teeostream<char> tee(one, two);
+ tee << "This is the " << 1 << '.' << " Test, we expect: " << std::boolalpha << true << "\n";
+ std::string okay("This is the 1. Test, we expect: true\n");
+ EXPECT_EQ(okay, one.str());
+ EXPECT_EQ(okay, two.str());
+ EXPECT_EQ(one.str(), two.str());
+}
+
+TEST(TeeStreamTest,DevNullSink1)
+{
+ std::ostringstream one;
+ std::fstream two("/dev/null");
+ basic_teeostream<char> tee(one, two);
+ tee << "This is the " << 2 << '.' << " Test, we expect: " << std::boolalpha << false << "\n";
+ std::string okay("This is the 2. Test, we expect: false\n");
+ EXPECT_EQ(okay, one.str());
+}
+
+TEST(TeeStreamTest,DevNullSink2)
+{
+ std::ostringstream one;
+ std::fstream two("/dev/null");
+ basic_teeostream<char> tee(two, one);
+ tee << "This is the " << 3 << '.' << " Test, we expect: " << std::boolalpha << false << "\n";
+ std::string okay("This is the 3. Test, we expect: false\n");
+ EXPECT_EQ(okay, one.str());
+}