Skip to content

Commit

Permalink
test: fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
eatradish committed Nov 14, 2024
1 parent 3711b9f commit 24ba6a7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 63 deletions.
12 changes: 6 additions & 6 deletions tests/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ mod cache {
use std::fmt::Write as _;

use cxx::{CxxVector, UniquePtr};
use rust_apt::cache::*;
use rust_apt::raw::{create_acquire, IntoRawIter, ItemDesc};
use rust_apt::util::*;
use rust_apt::{new_cache, DepType};
use oma_apt::cache::*;
use oma_apt::raw::{create_acquire, IntoRawIter, ItemDesc};
use oma_apt::util::*;
use oma_apt::{new_cache, DepType};

// This is a manual test. I don't know a good way to dynamically test this
// Maybe by installing a test-deb with certain depends and checking the
Expand Down Expand Up @@ -157,7 +157,7 @@ mod cache {
}

// This should not segfault, but has in the past.
// See https://gitlab.com/volian/rust-apt/-/issues/28
// See https://gitlab.com/volian/oma-apt/-/issues/28
#[test]
fn no_description() {
let cache = new_cache!(&["tests/files/cache/no-description_0.0.1.deb"]).unwrap();
Expand Down Expand Up @@ -360,7 +360,7 @@ mod cache {
for pkg in cache.packages(&sort) {
// Iterate over the reverse depends
// Iterating rdepends could segfault.
// See: https://gitlab.com/volian/rust-apt/-/merge_requests/36
// See: https://gitlab.com/volian/oma-apt/-/merge_requests/36
for deps in pkg.rdepends().values() {
for dep in deps {
let base_dep = dep.first();
Expand Down
57 changes: 0 additions & 57 deletions tests/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,61 +154,4 @@ mod config {
}
}
}

#[test]
fn get_architectures() {
let config = Config::new();

let output = dbg!(
String::from_utf8(
Command::new("dpkg")
.arg("--print-architecture")
.output()
.unwrap()
.stdout,
)
.unwrap()
);

let arches = dbg!(config.get_architectures());

assert!(arches.contains(&output.strip_suffix('\n').unwrap().to_string()));
}

#[test]
fn config_tree() {
// An example of how you might walk the entire config tree.
let config = Config::new();

let Some(tree) = config.root_tree() else {
return;
};

let mut stack = VecDeque::new();
stack.push_back((tree, 0));

while let Some((node, indent)) = stack.pop_back() {
let indent_str = " ".repeat(indent);

if let Some(item) = node.sibling() {
stack.push_back((item, indent));
}

if let Some(item) = node.child() {
stack.push_back((item, indent + 2));
}

if let Some(tag) = node.tag() {
if !tag.is_empty() {
println!("{}Tag: {}", indent_str, tag);
}
}

if let Some(value) = node.value() {
if !value.is_empty() {
println!("{}Value: {}", indent_str, value);
}
}
}
}
}

0 comments on commit 24ba6a7

Please sign in to comment.