git-next/crates/server/src/gitforge/tests/common.rs

69 lines
1.6 KiB
Rust
Raw Normal View History

use git_next_config::{
ApiToken, BranchName, ForgeDetails, ForgeName, ForgeType, GitDir, Hostname, RepoAlias,
RepoBranches, RepoConfig, RepoConfigSource, RepoPath, User,
};
use git_next_git::{Generation, RepoDetails};
pub fn forge_details(n: u32, forge_type: ForgeType) -> ForgeDetails {
ForgeDetails::new(
forge_name(n),
forge_type,
hostname(n),
user(n),
api_token(n),
)
}
pub fn api_token(n: u32) -> ApiToken {
ApiToken::new(format!("api-{}", n).into())
}
pub fn user(n: u32) -> User {
User::new(format!("user-{}", n))
}
pub fn hostname(n: u32) -> Hostname {
2024-05-14 07:59:31 +01:00
Hostname::new(format!("hostname-{}", n))
}
pub fn forge_name(n: u32) -> ForgeName {
ForgeName::new(format!("forge-name-{}", n))
}
2024-04-21 18:48:49 +01:00
pub fn repo_details(
n: u32,
generation: Generation,
2024-04-21 18:48:49 +01:00
forge: ForgeDetails,
repo_config: Option<RepoConfig>,
2024-04-23 07:09:30 +01:00
gitdir: GitDir,
2024-04-21 18:48:49 +01:00
) -> RepoDetails {
RepoDetails {
generation,
repo_alias: repo_alias(n),
repo_path: repo_path(n),
2024-04-21 18:48:49 +01:00
gitdir,
branch: branch_name(n),
forge,
repo_config,
}
}
pub fn branch_name(n: u32) -> BranchName {
BranchName::new(format!("branch-name-{}", n))
}
pub fn repo_path(n: u32) -> RepoPath {
RepoPath::new(format!("repo-path-{}", n))
}
pub fn repo_alias(n: u32) -> RepoAlias {
2024-05-14 07:59:31 +01:00
RepoAlias::new(format!("repo-alias-{}", n))
}
pub fn repo_config(n: u32, source: RepoConfigSource) -> RepoConfig {
RepoConfig::new(
RepoBranches::new(format!("main-{n}"), format!("next-{n}"), format!("dev-{n}")),
source,
)
}