Initial commit: apt-wrapper - Simple APT transaction wrapper
- Core transaction API with add_package, resolve, commit, rollback - Version tracking for upgrades/downgrades - Simple package info with FFI conversion functions - Comprehensive error handling - Basic test suite - Clean, minimal implementation (~326 lines total)
This commit is contained in:
commit
7aaefb9957
10 changed files with 761 additions and 0 deletions
50
tests/unit/test_basic.rs
Normal file
50
tests/unit/test_basic.rs
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
//! Unit tests for basic functionality
|
||||
|
||||
use apt_wrapper::{AptTransaction, AptPackage, AptRepository, PackageDatabase};
|
||||
|
||||
#[test]
|
||||
fn test_transaction_creation() {
|
||||
let transaction = AptTransaction::new().unwrap();
|
||||
assert!(transaction.is_empty());
|
||||
assert_eq!(transaction.packages().len(), 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_transaction_add_package() {
|
||||
let mut transaction = AptTransaction::new().unwrap();
|
||||
transaction.add_package("vim").unwrap();
|
||||
assert!(!transaction.is_empty());
|
||||
assert_eq!(transaction.packages().len(), 1);
|
||||
assert_eq!(transaction.packages()[0], "vim");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_transaction_resolve() {
|
||||
let mut transaction = AptTransaction::new().unwrap();
|
||||
transaction.add_package("vim").unwrap();
|
||||
transaction.resolve().unwrap();
|
||||
// Should not panic
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_package_creation() {
|
||||
let package = AptPackage::new("vim".to_string(), "2:8.2.2434-3+deb11u1".to_string());
|
||||
assert_eq!(package.name(), "vim");
|
||||
assert_eq!(package.version(), "2:8.2.2434-3+deb11u1");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_repository_creation() {
|
||||
let repo = AptRepository::new(
|
||||
"debian".to_string(),
|
||||
"http://deb.debian.org/debian".to_string(),
|
||||
);
|
||||
assert_eq!(repo.name(), "debian");
|
||||
assert_eq!(repo.url(), "http://deb.debian.org/debian");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_package_database_creation() {
|
||||
let db = PackageDatabase::new().unwrap();
|
||||
assert!(!db.is_stale());
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue