51 lines
1.3 KiB
Rust
51 lines
1.3 KiB
Rust
|
//
|
||
|
use super::*;
|
||
|
|
||
|
use git_next_config as config;
|
||
|
use git_next_git::{self as git, RepoDetails};
|
||
|
|
||
|
#[test]
|
||
|
fn test_mock_name() {
|
||
|
let net = Network::new_mock();
|
||
|
let repo_details = given_repo_details(config::ForgeType::MockForge);
|
||
|
let forge = Forge::new(repo_details, net);
|
||
|
assert_eq!(forge.name(), "mock");
|
||
|
}
|
||
|
|
||
|
#[test]
|
||
|
fn test_forgejo_name() {
|
||
|
let net = Network::new_mock();
|
||
|
let repo_details = given_repo_details(config::ForgeType::ForgeJo);
|
||
|
let forge = Forge::new(repo_details, net);
|
||
|
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::new(repo_details, net);
|
||
|
assert_eq!(forge.name(), "github");
|
||
|
}
|
||
|
|
||
|
fn given_fs() -> kxio::fs::FileSystem {
|
||
|
kxio::fs::temp().unwrap_or_else(|e| {
|
||
|
eprintln!("{e}");
|
||
|
panic!("fs")
|
||
|
})
|
||
|
}
|
||
|
|
||
|
fn given_repo_details(forge_type: config::ForgeType) -> RepoDetails {
|
||
|
let fs = given_fs();
|
||
|
git::common::repo_details(
|
||
|
1,
|
||
|
git::Generation::new(),
|
||
|
config::common::forge_details(1, forge_type),
|
||
|
Some(config::common::repo_config(
|
||
|
1,
|
||
|
config::RepoConfigSource::Repo,
|
||
|
)),
|
||
|
config::GitDir::new(fs.base()),
|
||
|
)
|
||
|
}
|