summaryrefslogtreecommitdiff
path: root/test/libapt/tagfile_test.cc
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2020-05-18 11:55:54 +0200
committerDavid Kalnischkies <david@kalnischkies.de>2020-05-18 15:55:36 +0200
commitc470d92366d7c3c239a689f0a10d6d0d9daafbff (patch)
tree955534f65524c3f81f36119012b6cd995a9619d0 /test/libapt/tagfile_test.cc
parent37cc8dcda9e97e0b9420d37bb886081fa629847d (diff)
Allow prefix to be a complete filename for GetTempFile
Our testcases had their own implementation of GetTempFile with the feature of a temporary file with a choosen suffix. Merging this into GetTempFile lets us drop this duplicate and hence test more our code rather than testing our helpers for test implementation. And then hashsums_test had another implementationā€¦ and extracttar wasn't even trying to use a real tempfileā€¦ one GetTempFile to rule them all! That also ensures that these tempfiles are created in a temporary directory rather than the current directory which is a nice touch and tries a little harder to clean up those tempfiles.
Diffstat (limited to 'test/libapt/tagfile_test.cc')
-rw-r--r--test/libapt/tagfile_test.cc12
1 files changed, 6 insertions, 6 deletions
diff --git a/test/libapt/tagfile_test.cc b/test/libapt/tagfile_test.cc
index 919b46cdb..06ea01c32 100644
--- a/test/libapt/tagfile_test.cc
+++ b/test/libapt/tagfile_test.cc
@@ -16,7 +16,7 @@
TEST(TagFileTest,SingleField)
{
FileFd fd;
- createTemporaryFile("singlefield", fd, NULL, "FieldA-12345678: the value of the field");
+ openTemporaryFile("singlefield", fd, "FieldA-12345678: the value of the field");
pkgTagFile tfile(&fd);
pkgTagSection section;
@@ -41,7 +41,7 @@ TEST(TagFileTest,SingleField)
EXPECT_FALSE(section.Exists("FieldA-12345678"));
EXPECT_FALSE(section.Exists("FieldB-12345678"));
- createTemporaryFile("emptyfile", fd, NULL, NULL);
+ openTemporaryFile("emptyfile", fd);
ASSERT_FALSE(tfile.Step(section));
EXPECT_EQ(0u, section.Count());
}
@@ -49,7 +49,7 @@ TEST(TagFileTest,SingleField)
TEST(TagFileTest,MultipleSections)
{
FileFd fd;
- createTemporaryFile("bigsection", fd, NULL, "Package: pkgA\n"
+ openTemporaryFile("bigsection", fd, "Package: pkgA\n"
"Version: 1\n"
"Size: 100\n"
"Description: aaa\n"
@@ -140,7 +140,7 @@ TEST(TagFileTest,BigSection)
content << "Field-" << i << ": " << (2000 + i) << std::endl;
FileFd fd;
- createTemporaryFile("bigsection", fd, NULL, content.str().c_str());
+ openTemporaryFile("bigsection", fd, content.str().c_str());
pkgTagFile tfile(&fd);
pkgTagSection section;
@@ -230,7 +230,7 @@ TEST(TagFileTest, SpacesEverywhere)
TEST(TagFileTest, Comments)
{
FileFd fd;
- createTemporaryFile("commentfile", fd, NULL, "# Leading comments should be ignored.\n"
+ openTemporaryFile("commentfile", fd, "# Leading comments should be ignored.\n"
"\n"
"# A wild second comment appears!\n"
"\n"
@@ -289,7 +289,7 @@ TEST(TagFileTest, Comments)
TEST(TagFileTest, EmptyTagName)
{
FileFd fd;
- createTemporaryFile("emptytagname", fd, NULL, "0:\n"
+ openTemporaryFile("emptytagname", fd, "0:\n"
"PACKAGE:0\n"
"\n"
":\n"