]> git.saurik.com Git - apt.git/blob - test/libapt/indexcopytosourcelist_test.cc
calculate only expected hashes in methods
[apt.git] / test / libapt / indexcopytosourcelist_test.cc
1 #include <config.h>
2
3 #include <apt-pkg/configuration.h>
4 #include <apt-pkg/aptconfiguration.h>
5 #include <apt-pkg/indexcopy.h>
6
7 #include <string>
8 #include <stdio.h>
9
10 #include <gtest/gtest.h>
11
12 class NoCopy : public IndexCopy {
13 public:
14 std::string ConvertToSourceList(std::string CD,std::string Path) {
15 IndexCopy::ConvertToSourceList(CD, Path);
16 return Path;
17 }
18 bool GetFile(std::string &/*Filename*/, unsigned long long &/*Size*/) { return false; }
19 bool RewriteEntry(FILE * /*Target*/, std::string /*File*/) { return false; }
20 const char *GetFileName() { return NULL; }
21 const char *Type() { return NULL; }
22
23 };
24
25 TEST(IndexCopyTest, ConvertToSourceList)
26 {
27 NoCopy ic;
28 std::string const CD("/media/cdrom/");
29
30 char const * Releases[] = { "unstable", "wheezy-updates", NULL };
31 char const * Components[] = { "main", "non-free", NULL };
32
33 for (char const ** Release = Releases; *Release != NULL; ++Release)
34 {
35 SCOPED_TRACE(std::string("Release ") + *Release);
36 for (char const ** Component = Components; *Component != NULL; ++Component)
37 {
38 SCOPED_TRACE(std::string("Component ") + *Component);
39 std::string const Path = std::string("dists/") + *Release + "/" + *Component + "/";
40 std::string const Binary = Path + "binary-";
41 std::string const A = Binary + "armel/";
42 std::string const B = Binary + "mips/";
43 std::string const C = Binary + "kfreebsd-mips/";
44 std::string const S = Path + "source/";
45 std::string const List = std::string(*Release) + " " + *Component;
46
47 _config->Clear("APT");
48 APT::Configuration::getArchitectures(false);
49 EXPECT_EQ(A, ic.ConvertToSourceList("/media/cdrom/", CD + A));
50 EXPECT_EQ(B, ic.ConvertToSourceList("/media/cdrom/", CD + B));
51 EXPECT_EQ(C, ic.ConvertToSourceList("/media/cdrom/", CD + C));
52 EXPECT_EQ(List, ic.ConvertToSourceList("/media/cdrom/", CD + S));
53
54 _config->Clear("APT");
55 _config->Set("APT::Architecture", "mips");
56 _config->Set("APT::Architectures::", "mips");
57 APT::Configuration::getArchitectures(false);
58 EXPECT_EQ(A, ic.ConvertToSourceList("/media/cdrom/", CD + A));
59 EXPECT_EQ(List, ic.ConvertToSourceList("/media/cdrom/", CD + B));
60 EXPECT_EQ(C, ic.ConvertToSourceList("/media/cdrom/", CD + C));
61 EXPECT_EQ(List, ic.ConvertToSourceList("/media/cdrom/", CD + S));
62
63 _config->Clear("APT");
64 _config->Set("APT::Architecture", "kfreebsd-mips");
65 _config->Set("APT::Architectures::", "kfreebsd-mips");
66 APT::Configuration::getArchitectures(false);
67 EXPECT_EQ(A, ic.ConvertToSourceList("/media/cdrom/", CD + A));
68 EXPECT_EQ(B, ic.ConvertToSourceList("/media/cdrom/", CD + B));
69 EXPECT_EQ(List, ic.ConvertToSourceList("/media/cdrom/", CD + C));
70 EXPECT_EQ(List, ic.ConvertToSourceList("/media/cdrom/", CD + S));
71
72 _config->Clear("APT");
73 _config->Set("APT::Architecture", "armel");
74 _config->Set("APT::Architectures::", "armel");
75 APT::Configuration::getArchitectures(false);
76 EXPECT_EQ(List, ic.ConvertToSourceList("/media/cdrom/", CD + A));
77 EXPECT_EQ(B, ic.ConvertToSourceList("/media/cdrom/", CD + B));
78 EXPECT_EQ(C, ic.ConvertToSourceList("/media/cdrom/", CD + C));
79 EXPECT_EQ(List, ic.ConvertToSourceList("/media/cdrom/", CD + S));
80
81 _config->Clear("APT");
82 _config->Set("APT::Architecture", "armel");
83 _config->Set("APT::Architectures::", "armel");
84 _config->Set("APT::Architectures::", "mips");
85 APT::Configuration::getArchitectures(false);
86 EXPECT_EQ(List, ic.ConvertToSourceList("/media/cdrom/", CD + A));
87 EXPECT_EQ(List, ic.ConvertToSourceList("/media/cdrom/", CD + B));
88 EXPECT_EQ(C, ic.ConvertToSourceList("/media/cdrom/", CD + C));
89 EXPECT_EQ(List, ic.ConvertToSourceList("/media/cdrom/", CD + S));
90 }
91 }
92 }