Debian Codegraph @

tests/depcache.rs

raw symbols SCIP
1 mod depcacherust-analyzer cargo rust-apt 0.8.0 depcache/ {
2 use rust_aptrust-analyzer cargo rust-apt 0.8.0 crate/::cacherust-analyzer cargo rust-apt 0.8.0 cache/::Upgraderust-analyzer cargo rust-apt 0.8.0 cache/Upgrade#;
3 use rust_aptrust-analyzer cargo rust-apt 0.8.0 crate/::new_cacherust-analyzer cargo rust-apt 0.8.0 macros/new_cache!;
4
5 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
6 fn mark_reinstallrust-analyzer cargo rust-apt 0.8.0 depcache/mark_reinstall().() {
7 let cache = new_cacherust-analyzer cargo rust-apt 0.8.0 macros/new_cache!!().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
8 let pkg = cache.getrust-analyzer cargo rust-apt 0.8.0 cache/impl#[Cache]get().("apt").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().();
9
10 dbgrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/dbg!!(pkg.marked_reinstallrust-analyzer cargo rust-apt 0.8.0 iterators/package/impl#[`Package<'a>`]marked_reinstall().());
11 dbgrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/dbg!!(pkg.mark_reinstallrust-analyzer cargo rust-apt 0.8.0 iterators/package/impl#[`Package<'a>`]mark_reinstall().(true));
12 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(pkg.marked_reinstallrust-analyzer cargo rust-apt 0.8.0 iterators/package/impl#[`Package<'a>`]marked_reinstall().());
13 }
14
15 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
16 fn action_groupsrust-analyzer cargo rust-apt 0.8.0 depcache/action_groups().() {
17 let cache = new_cacherust-analyzer cargo rust-apt 0.8.0 macros/new_cache!!().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
18 let mut action_group = unsafe { cache.depcacherust-analyzer cargo rust-apt 0.8.0 cache/impl#[Cache]depcache().().action_grouprust-analyzer cargo rust-apt 0.8.0 depcache/raw/impl#[PkgDepCache]action_group().() };
19
20 // This is unsafe due to SIGABRT if you try to release after dropping the cache.
21 // Probably should get wrapped and have a lifetime related to the Cache.
22 // drop(cache);
23
24 // The C++ deconstructor will be run when the action group leaves scope.
25 action_group.pin_mutrust-analyzer cargo cxx 1.0.199 unique_ptr/impl#[`UniquePtr<T>`]pin_mut().().releaserust-analyzer cargo rust-apt 0.8.0 depcache/raw/impl#[ActionGroup]release().();
26 }
27
28 // Make a test for getting the candidate after you set a candidate.
29 // Make sure it's the expected version.
30 // We had to change to getting the candidate from the depcache.
31 // https://gitlab.com/volian/rust-apt/-/issues/14
32
33 // #[test]
34 // fn changes_test() {
35 // let cache = new_cache!().unwrap();
36
37 // let pkg = cache.get("nala").unwrap();
38
39 // let ver = pkg.get_version("0.12.1").unwrap();
40
41 // ver.set_candidate();
42
43 // let cand = pkg.candidate().unwrap();
44
45 // println!("Version is {}", cand.version())
46 // }
47
48 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
49 fn upgraderust-analyzer cargo rust-apt 0.8.0 depcache/upgrade().() {
50 // There isn't a great way to test if upgrade is working properly
51 // as this is dynamic depending on the system.
52 // This test will always pass, but print the status of the changes.
53 // Occasionally manually compare the output to apt full-upgrade.
54 let cache = new_cacherust-analyzer cargo rust-apt 0.8.0 macros/new_cache!!().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
55 cache.upgraderust-analyzer cargo rust-apt 0.8.0 cache/impl#[Cache]upgrade().(Upgraderust-analyzer cargo rust-apt 0.8.0 cache/Upgrade#::FullUpgraderust-analyzer cargo rust-apt 0.8.0 cache/Upgrade#FullUpgrade#).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
56
57 for pkg in cache.get_changesrust-analyzer cargo rust-apt 0.8.0 cache/impl#[Cache]get_changes().(true) {
58 if pkg.marked_installrust-analyzer cargo rust-apt 0.8.0 iterators/package/impl#[`Package<'a>`]marked_install().() {
59 printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("{} is marked install", pkg.namerust-analyzer cargo rust-apt 0.8.0 iterators/package/raw/impl#[PkgIterator]name().());
60 // If the package is marked install then it will also
61 // show up as marked upgrade, downgrade etc.
62 // Check this first and continue.
63 continue;
64 }
65 if pkg.marked_upgraderust-analyzer cargo rust-apt 0.8.0 iterators/package/impl#[`Package<'a>`]marked_upgrade().() {
66 printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("{} is marked upgrade", pkg.namerust-analyzer cargo rust-apt 0.8.0 iterators/package/raw/impl#[PkgIterator]name().())
67 }
68 if pkg.marked_deleterust-analyzer cargo rust-apt 0.8.0 iterators/package/impl#[`Package<'a>`]marked_delete().() {
69 printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("{} is marked remove", pkg.namerust-analyzer cargo rust-apt 0.8.0 iterators/package/raw/impl#[PkgIterator]name().())
70 }
71 if pkg.marked_reinstallrust-analyzer cargo rust-apt 0.8.0 iterators/package/impl#[`Package<'a>`]marked_reinstall().() {
72 printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("{} is marked reinstall", pkg.namerust-analyzer cargo rust-apt 0.8.0 iterators/package/raw/impl#[PkgIterator]name().())
73 }
74 if pkg.marked_downgraderust-analyzer cargo rust-apt 0.8.0 iterators/package/impl#[`Package<'a>`]marked_downgrade().() {
75 printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("{} is marked downgrade", pkg.namerust-analyzer cargo rust-apt 0.8.0 iterators/package/raw/impl#[PkgIterator]name().())
76 }
77 }
78 }
79 }