hoc/tests/count.rs

67 lines
2.1 KiB
Rust
Raw Normal View History

2022-08-22 15:12:21 +02:00
use hoc::count::count_repositories;
use tempfile::TempDir;
#[test]
fn no_repos() {
let repos = TempDir::new().unwrap();
2023-07-27 10:44:26 +02:00
assert_eq!(0, count_repositories(&repos).unwrap());
2022-08-22 15:12:21 +02:00
}
#[test]
fn no_repos_for_provider() {
let repos = TempDir::new().unwrap();
let _provider = TempDir::new_in(&repos).unwrap();
2023-07-27 10:44:26 +02:00
assert_eq!(0, count_repositories(&repos).unwrap());
2022-08-22 15:12:21 +02:00
}
#[test]
fn no_repos_for_owner() {
let repos = TempDir::new().unwrap();
let provider = TempDir::new_in(&repos).unwrap();
let _owner = TempDir::new_in(&provider).unwrap();
2023-07-27 10:44:26 +02:00
assert_eq!(0, count_repositories(&repos).unwrap());
2022-08-22 15:12:21 +02:00
}
#[test]
fn one_repo_for_owner() {
let repos = TempDir::new().unwrap();
let provider = TempDir::new_in(&repos).unwrap();
let owner = TempDir::new_in(&provider).unwrap();
let _repo = TempDir::new_in(&owner).unwrap();
2023-07-27 10:44:26 +02:00
assert_eq!(1, count_repositories(&repos).unwrap());
2022-08-22 15:12:21 +02:00
}
#[test]
fn two_repos_for_owner() {
let repos = TempDir::new().unwrap();
let provider = TempDir::new_in(&repos).unwrap();
let owner = TempDir::new_in(&provider).unwrap();
let _repo1 = TempDir::new_in(&owner).unwrap();
let _repo2 = TempDir::new_in(&owner).unwrap();
2023-07-27 10:44:26 +02:00
assert_eq!(2, count_repositories(&repos).unwrap());
2022-08-22 15:12:21 +02:00
}
#[test]
fn two_repos_for_two_providers() {
let repos = TempDir::new().unwrap();
let provider1 = TempDir::new_in(&repos).unwrap();
let owner1 = TempDir::new_in(&provider1).unwrap();
let _repo1 = TempDir::new_in(&owner1).unwrap();
let provider2 = TempDir::new_in(&repos).unwrap();
let owner2 = TempDir::new_in(&provider2).unwrap();
let _repo2 = TempDir::new_in(&owner2).unwrap();
2023-07-27 10:44:26 +02:00
assert_eq!(2, count_repositories(&repos).unwrap());
2022-08-22 15:12:21 +02:00
}
#[test]
fn two_subdirs_in_one_repo() {
let repos = TempDir::new().unwrap();
let provider = TempDir::new_in(&repos).unwrap();
let owner = TempDir::new_in(&provider).unwrap();
let repo = TempDir::new_in(&owner).unwrap();
let _subdir1 = TempDir::new_in(&repo).unwrap();
let _subdir2 = TempDir::new_in(&repo).unwrap();
2023-07-27 10:44:26 +02:00
assert_eq!(1, count_repositories(&repos).unwrap());
2022-08-22 15:12:21 +02:00
}