]> git.saurik.com Git - apt.git/blob - test/libapt/cdromfindpackages_test.cc
show upgradable packages after apt update
[apt.git] / test / libapt / cdromfindpackages_test.cc
1 #include <config.h>
2
3 #include <apt-pkg/cdrom.h>
4 #include <apt-pkg/error.h>
5
6 #include <algorithm>
7 #include <string>
8 #include <vector>
9 #include <stddef.h>
10 #include <iostream>
11
12 #include "assert.h"
13
14 class Cdrom : public pkgCdrom {
15 public:
16 bool FindPackages(std::string const &CD,
17 std::vector<std::string> &List,
18 std::vector<std::string> &SList,
19 std::vector<std::string> &SigList,
20 std::vector<std::string> &TransList,
21 std::string &InfoDir) {
22 bool const result = pkgCdrom::FindPackages(CD, List, SList, SigList, TransList, InfoDir, NULL, 0);
23 std::sort(List.begin(), List.end());
24 std::sort(SList.begin(), SList.end());
25 std::sort(SigList.begin(), SigList.end());
26 std::sort(TransList.begin(), TransList.end());
27 return result;
28 }
29
30 bool DropRepeats(std::vector<std::string> &List, char const *Name) {
31 return pkgCdrom::DropRepeats(List, Name);
32 }
33 };
34
35 int main(int argc, char const *argv[]) {
36 if (argc != 2) {
37 std::cout << "One parameter expected - given " << argc << std::endl;
38 return 100;
39 }
40
41 Cdrom cd;
42 std::vector<std::string> Packages, Sources, Signatur, Translation;
43 std::string InfoDir;
44 std::string path = argv[1];
45 equals(true, cd.FindPackages(path, Packages, Sources, Signatur, Translation, InfoDir));
46 equals(4, Packages.size());
47 equals(path + "/dists/sid/main/binary-i386/", Packages[0]);
48 equals(path + "/dists/stable/contrib/binary-amd64/", Packages[1]);
49 equals(path + "/dists/stable/main/binary-i386/", Packages[2]);
50 equals(path + "/dists/unstable/main/binary-i386/", Packages[3]);
51 equals(3, Sources.size());
52 equals(path + "/dists/sid/main/source/", Sources[0]);
53 equals(path + "/dists/stable/main/source/", Sources[1]);
54 equals(path + "/dists/unstable/main/source/", Sources[2]);
55 equals(3, Signatur.size());
56 equals(path + "/dists/sid/", Signatur[0]);
57 equals(path + "/dists/stable/", Signatur[1]);
58 equals(path + "/dists/unstable/", Signatur[2]);
59 equals(4, Translation.size());
60 equals(path + "/dists/sid/main/i18n/Translation-de", Translation[0]);
61 equals(path + "/dists/sid/main/i18n/Translation-en", Translation[1]);
62 equals(path + "/dists/unstable/main/i18n/Translation-de", Translation[2]);
63 equals(path + "/dists/unstable/main/i18n/Translation-en", Translation[3]);
64 equals(path + "/.disk/", InfoDir);
65
66 cd.DropRepeats(Packages, "Packages");
67 cd.DropRepeats(Sources, "Sources");
68 _error->PushToStack();
69 cd.DropRepeats(Signatur, "InRelease");
70 cd.DropRepeats(Signatur, "Release.gpg");
71 _error->RevertToStack();
72 _error->DumpErrors();
73 cd.DropRepeats(Translation, "");
74
75 equals(3, Packages.size());
76 equals(path + "/dists/stable/contrib/binary-amd64/", Packages[0]);
77 equals(path + "/dists/stable/main/binary-i386/", Packages[1]);
78 equals(path + "/dists/unstable/main/binary-i386/", Packages[2]);
79 equals(2, Sources.size());
80 equals(path + "/dists/stable/main/source/", Sources[0]);
81 equals(path + "/dists/unstable/main/source/", Sources[1]);
82 equals(2, Signatur.size());
83 equals(path + "/dists/stable/", Signatur[0]);
84 equals(path + "/dists/unstable/", Signatur[1]);
85 equals(2, Translation.size());
86 equals(path + "/dists/unstable/main/i18n/Translation-de", Translation[0]);
87 equals(path + "/dists/unstable/main/i18n/Translation-en", Translation[1]);
88
89 return 0;
90 }