test: Create stub mock forge
All checks were successful
ci/woodpecker/push/cron-docker-builder Pipeline was successful
ci/woodpecker/push/tag-created Pipeline was successful
ci/woodpecker/push/push-next Pipeline was successful
ci/woodpecker/cron/push-next Pipeline was successful
ci/woodpecker/cron/tag-created Pipeline was successful
ci/woodpecker/cron/cron-docker-builder Pipeline was successful
All checks were successful
ci/woodpecker/push/cron-docker-builder Pipeline was successful
ci/woodpecker/push/tag-created Pipeline was successful
ci/woodpecker/push/push-next Pipeline was successful
ci/woodpecker/cron/push-next Pipeline was successful
ci/woodpecker/cron/tag-created Pipeline was successful
ci/woodpecker/cron/cron-docker-builder Pipeline was successful
Still need to figure out what tests this will need to support, and how to configure it's behaviour. I've not ruled out creating a forge object that is passed in rather than the functions we have now. Closes kemitix/git-next#37
This commit is contained in:
parent
1ffa8366e0
commit
3bbe9abbd9
7 changed files with 54 additions and 0 deletions
|
@ -20,6 +20,10 @@ pub async fn validate_positions(
|
|||
config::ForgeType::ForgeJo => {
|
||||
forge::forgejo::get_commit_histories(&repo_details, &config, &net).await
|
||||
}
|
||||
#[cfg(test)]
|
||||
config::ForgeType::MockForge => {
|
||||
forge::mock::get_commit_histories(&repo_details, &config, &net).await
|
||||
}
|
||||
};
|
||||
let commit_histories = match commit_histories {
|
||||
Ok(commit_histories) => commit_histories,
|
||||
|
|
|
@ -13,6 +13,8 @@ pub async fn load(details: RepoDetails, addr: Addr<RepoActor>, net: Network) {
|
|||
let config = match details.forge.forge_type {
|
||||
#[cfg(feature = "forgejo")]
|
||||
ForgeType::ForgeJo => forge::forgejo::config::load(&details, &net).await,
|
||||
#[cfg(test)]
|
||||
ForgeType::MockForge => forge::mock::config::load(&details, &net).await,
|
||||
};
|
||||
match config {
|
||||
Ok(config) => addr.do_send(LoadedConfig(config)),
|
||||
|
|
|
@ -22,6 +22,10 @@ pub async fn check_next(
|
|||
ForgeType::ForgeJo => {
|
||||
forge::forgejo::get_commit_status(next.clone(), &repo_details, net).await
|
||||
}
|
||||
#[cfg(test)]
|
||||
ForgeType::MockForge => {
|
||||
forge::mock::get_commit_status(next.clone(), &repo_details, &net).await
|
||||
}
|
||||
};
|
||||
info!(?status, "Checking next branch");
|
||||
match status {
|
||||
|
|
|
@ -259,6 +259,8 @@ pub enum ForgeType {
|
|||
// GitHub,
|
||||
// GitLab,
|
||||
// BitBucket,
|
||||
#[cfg(test)]
|
||||
MockForge,
|
||||
}
|
||||
impl Display for ForgeType {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
|
|
16
src/server/forge/mock/config.rs
Normal file
16
src/server/forge/mock/config.rs
Normal file
|
@ -0,0 +1,16 @@
|
|||
pub(crate) async fn load(
|
||||
_details: &crate::server::config::RepoDetails,
|
||||
_net: &kxio::network::Network,
|
||||
) -> Result<
|
||||
crate::server::config::RepoConfig,
|
||||
terrors::OneOf<(
|
||||
crate::server::forge::forgejo::config::RepoConfigFileNotFound,
|
||||
crate::server::forge::forgejo::config::RepoConfigIsNotFile,
|
||||
crate::server::forge::forgejo::config::RepoConfigDecodeError,
|
||||
crate::server::forge::forgejo::config::RepoConfigParseError,
|
||||
crate::server::forge::forgejo::config::RepoConfigUnknownError,
|
||||
crate::server::forge::forgejo::config::RepoConfigBranchNotFound,
|
||||
)>,
|
||||
> {
|
||||
todo!()
|
||||
}
|
24
src/server/forge/mock/mod.rs
Normal file
24
src/server/forge/mock/mod.rs
Normal file
|
@ -0,0 +1,24 @@
|
|||
use kxio::network::{Network, NetworkError};
|
||||
|
||||
use crate::server::{
|
||||
config::{RepoConfig, RepoDetails},
|
||||
forge::CommitHistories,
|
||||
};
|
||||
|
||||
pub mod config;
|
||||
|
||||
pub(crate) async fn get_commit_histories(
|
||||
_repo_details: &RepoDetails,
|
||||
_config: &RepoConfig,
|
||||
_net: &Network,
|
||||
) -> Result<CommitHistories, NetworkError> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
pub(crate) async fn get_commit_status(
|
||||
_clone: super::Commit,
|
||||
_repo_details: &RepoDetails,
|
||||
_net: &Network,
|
||||
) -> crate::server::actors::repo::status::Status {
|
||||
todo!()
|
||||
}
|
|
@ -3,6 +3,8 @@ use std::fmt::{Display, Formatter};
|
|||
#[cfg(feature = "forgejo")]
|
||||
pub mod forgejo;
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod mock;
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
|
|
Loading…
Reference in a new issue