ostree/cargo: bump to ostree-sys 0.9.2

This commit is contained in:
Luca BRUNO authored and Colin Walters committed 2022-05-06 12:53:57 -04:00
1 parent 61b4629b37
commit 3fc55a524b
91 files changed
+2 -1

No files matched your search

+79
View File
@@ -0,0 +1,79 @@
#![cfg(feature = "v2018_6")]
use crate::CollectionRef;
use std::collections::hash_map::DefaultHasher;
use std::hash::{Hash, Hasher};
fn hash(v: &impl Hash) -> u64 {
let mut s = DefaultHasher::new();
v.hash(&mut s);
s.finish()
}
#[test]
fn same_value_should_be_equal() {
let r = CollectionRef::new(Some("io.gitlab.fkrull"), "ref").unwrap();
assert_eq!(r, r);
}
#[test]
fn equal_values_should_be_equal() {
let a = CollectionRef::new(Some("io.gitlab.fkrull"), "ref").unwrap();
let b = CollectionRef::new(Some("io.gitlab.fkrull"), "ref").unwrap();
assert_eq!(a, b);
}
#[test]
fn equal_values_without_collection_id_should_be_equal() {
let a = CollectionRef::new(None, "ref-name").unwrap();
let b = CollectionRef::new(None, "ref-name").unwrap();
assert_eq!(a, b);
}
#[test]
fn different_values_should_not_be_equal() {
let a = CollectionRef::new(Some("io.gitlab.fkrull"), "ref1").unwrap();
let b = CollectionRef::new(Some("io.gitlab.fkrull"), "ref2").unwrap();
assert_ne!(a, b);
}
#[test]
fn new_with_invalid_collection_id_should_return_none() {
let r = CollectionRef::new(Some(".abc"), "ref");
assert_eq!(r, None);
}
#[test]
fn hash_for_equal_values_should_be_equal() {
let a = CollectionRef::new(Some("io.gitlab.fkrull"), "ref").unwrap();
let b = CollectionRef::new(Some("io.gitlab.fkrull"), "ref").unwrap();
assert_eq!(hash(&a), hash(&b));
}
#[test]
fn hash_for_values_with_different_collection_id_should_be_different() {
let a = CollectionRef::new(Some("io.gitlab.fkrull1"), "ref").unwrap();
let b = CollectionRef::new(Some("io.gitlab.fkrull2"), "ref").unwrap();
assert_ne!(hash(&a), hash(&b));
}
#[test]
fn hash_for_values_with_different_ref_id_should_be_different() {
let a = CollectionRef::new(Some("io.gitlab.fkrull"), "ref-1").unwrap();
let b = CollectionRef::new(Some("io.gitlab.fkrull"), "ref-2").unwrap();
assert_ne!(hash(&a), hash(&b));
}
#[test]
fn hash_should_be_different_if_collection_id_is_absent() {
let a = CollectionRef::new(Some("io.gitlab.fkrull"), "ref").unwrap();
let b = CollectionRef::new(None, "ref").unwrap();
assert_ne!(hash(&a), hash(&b));
}
#[test]
fn clone_should_be_equal_to_original_value() {
let a = CollectionRef::new(Some("io.gitlab.fkrull"), "ref").unwrap();
let b = a.clone();
assert_eq!(a, b);
}
+64
View File
@@ -0,0 +1,64 @@
#![cfg(feature = "v2019_3")]
use crate::KernelArgs;
#[test]
fn should_create_and_fill_kernel_args() {
let mut args = KernelArgs::new();
args.append("key=value");
args.append("arg1");
args.append("key2=value2");
assert_eq!(args.to_string(), "key=value arg1 key2=value2");
}
#[test]
fn should_convert_to_string_vec() {
let mut args = KernelArgs::new();
args.parse_append("key=value arg1 key2=value2");
assert_eq!(
args.to_strv()
.iter()
.map(|s| s.as_str())
.collect::<Vec<_>>(),
vec!["key=value", "arg1", "key2=value2"]
);
}
#[test]
fn should_get_last_value() {
let mut args = KernelArgs::new();
args.append("key=value1");
args.append("key=value2");
args.append("key=value3");
assert_eq!(args.get_last_value("key").unwrap(), "value3");
}
#[test]
fn should_convert_from_string() {
let args = KernelArgs::from(String::from("arg1 arg2 arg3=value"));
assert_eq!(args.to_strv(), vec!["arg1", "arg2", "arg3=value"]);
}
#[test]
fn should_append_argv() {
let mut args = KernelArgs::new();
args.append_argv(&["arg1", "arg2=value", "arg3", "arg4=value"]);
assert_eq!(args.to_string(), "arg1 arg2=value arg3 arg4=value");
}
#[test]
fn should_append_argv_filtered() {
let mut args = KernelArgs::new();
args.append_argv_filtered(
&["prefix.arg1", "arg2", "prefix.arg3", "arg4=value"],
&["prefix"],
);
assert_eq!(args.to_string(), "arg2 arg4=value");
}
#[test]
fn should_replace_argv() {
let mut args = KernelArgs::from_string("arg1=value1 arg2=value2 arg3");
args.replace_argv(&["arg1=value3", "arg3=value4", "arg4"]);
assert_eq!(args.to_string(), "arg1=value3 arg2=value2 arg3=value4 arg4");
}
+3
View File
@@ -0,0 +1,3 @@
mod collection_ref;
mod kernel_args;
mod repo;
+14
View File
@@ -0,0 +1,14 @@
use crate::Repo;
use crate::RepoMode;
#[test]
fn should_get_repo_mode_from_string() {
let mode = Repo::mode_from_string("archive").unwrap();
assert_eq!(RepoMode::Archive, mode);
}
#[test]
fn should_return_error_for_invalid_repo_mode_string() {
let result = Repo::mode_from_string("invalid-repo-mode");
assert!(result.is_err());
}