Files
apt/test/libapt/sourcelist_test.cc
David Kalnischkies c470d92366 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.
2020-05-18 15:55:36 +02:00

34 lines
774 B
C++

#include <config.h>
#include <apt-pkg/fileutl.h>
#include <apt-pkg/sourcelist.h>
#include <string>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <gtest/gtest.h>
#include "file-helpers.h"
TEST(SourceListTest,ParseFileDeb822)
{
auto const file = createTemporaryFile("parsefiledeb822.XXXXXX.sources",
"Types: deb\n"
"URIs: http://ftp.debian.org/debian\n"
"Suites: stable\n"
"Components: main\n"
"Description: short\n"
" long description that can be very long\n"
"\n"
"Types: deb\n"
"URIs: http://ftp.debian.org/debian\n"
"Suites: unstable\n"
"Components: main non-free\n");
pkgSourceList sources;
EXPECT_TRUE(sources.Read(file.Name()));
EXPECT_EQ(2u, sources.size());
}