diff options
author | David Kalnischkies <david@kalnischkies.de> | 2020-05-18 11:55:54 +0200 |
---|---|---|
committer | David Kalnischkies <david@kalnischkies.de> | 2020-05-18 15:55:36 +0200 |
commit | c470d92366d7c3c239a689f0a10d6d0d9daafbff (patch) | |
tree | 955534f65524c3f81f36119012b6cd995a9619d0 /test/libapt/sourcelist_test.cc | |
parent | 37cc8dcda9e97e0b9420d37bb886081fa629847d (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/sourcelist_test.cc')
-rw-r--r-- | test/libapt/sourcelist_test.cc | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/test/libapt/sourcelist_test.cc b/test/libapt/sourcelist_test.cc index 9441f56be..42fab65a9 100644 --- a/test/libapt/sourcelist_test.cc +++ b/test/libapt/sourcelist_test.cc @@ -14,9 +14,7 @@ TEST(SourceListTest,ParseFileDeb822) { - FileFd fd; - std::string tempfile; - createTemporaryFile("parsefiledeb822.XXXXXX.sources", fd, &tempfile, + auto const file = createTemporaryFile("parsefiledeb822.XXXXXX.sources", "Types: deb\n" "URIs: http://ftp.debian.org/debian\n" "Suites: stable\n" @@ -28,12 +26,8 @@ TEST(SourceListTest,ParseFileDeb822) "URIs: http://ftp.debian.org/debian\n" "Suites: unstable\n" "Components: main non-free\n"); - fd.Close(); pkgSourceList sources; - EXPECT_EQ(true, sources.Read(tempfile)); + EXPECT_TRUE(sources.Read(file.Name())); EXPECT_EQ(2u, sources.size()); - - if (tempfile.empty() == false) - unlink(tempfile.c_str()); } |