git-next/crates/forge/src/tests.rs

46 lines
1.2 KiB
Rust
Raw Normal View History

2024-06-01 12:03:30 +01:00
//
use super::*;
use git_next_config as config;
use git_next_git::{self as git, RepoDetails};
#[test]
fn test_forgejo_name() {
let net = Network::new_mock();
let repo_details = given_repo_details(config::ForgeType::ForgeJo);
let forge = Forge::create(repo_details, net);
2024-06-01 12:03:30 +01:00
assert_eq!(forge.name(), "forgejo");
}
#[test]
fn test_github_name() {
let net = Network::new_mock();
let repo_details = given_repo_details(config::ForgeType::GitHub);
let forge = Forge::create(repo_details, net);
2024-06-01 12:03:30 +01:00
assert_eq!(forge.name(), "github");
}
fn given_fs() -> kxio::fs::FileSystem {
kxio::fs::temp().unwrap_or_else(|e| {
println!("{e}");
2024-06-01 12:03:30 +01:00
panic!("fs")
})
}
fn given_repo_details(forge_type: config::ForgeType) -> RepoDetails {
let fs = given_fs();
git::common::repo_details(
1,
2024-06-20 19:03:11 +01:00
git::Generation::default(),
2024-06-01 12:03:30 +01:00
config::common::forge_details(1, forge_type),
Some(config::common::repo_config(
1,
config::RepoConfigSource::Repo,
)),
config::GitDir::new(
fs.base().to_path_buf(),
config::git_dir::StoragePathType::Internal,
),
2024-06-01 12:03:30 +01:00
)
}