pub mod github_steps;
pub mod registry_steps;
#[cfg(feature = "git")]
pub mod repo_read_paths_steps;
#[cfg(feature = "git")]
pub mod repo_steps;
#[cfg(feature = "git")]
pub mod repo_write_paths_steps;
use std::sync::Arc;
use async_trait::async_trait;
use cucumber::World;
use rtb_vcs::release::{
ProviderError, ProviderFactory, ProviderRegistration, RegisteredProvider, Release,
ReleaseAsset, ReleaseProvider, RELEASE_PROVIDERS,
};
use rtb_vcs::ReleaseSourceConfig;
use secrecy::SecretString;
use tokio::io::AsyncRead;
pub struct MockProvider;
#[async_trait]
impl ReleaseProvider for MockProvider {
async fn latest_release(&self) -> Result<Release, ProviderError> {
Ok(Release::new("v1.0.0", "v1.0.0", time::OffsetDateTime::UNIX_EPOCH))
}
async fn release_by_tag(&self, _tag: &str) -> Result<Release, ProviderError> {
Ok(Release::new("v1.0.0", "v1.0.0", time::OffsetDateTime::UNIX_EPOCH))
}
async fn list_releases(&self, _limit: usize) -> Result<Vec<Release>, ProviderError> {
Ok(vec![])
}
async fn download_asset(
&self,
_asset: &ReleaseAsset,
) -> Result<(Box<dyn AsyncRead + Send + Unpin>, u64), ProviderError> {
let buf: &[u8] = b"";
Ok((Box::new(buf), 0))
}
}
#[allow(clippy::unnecessary_wraps)]
pub fn mock_factory(
_cfg: &ReleaseSourceConfig,
_token: Option<SecretString>,
) -> Result<Arc<dyn ReleaseProvider>, ProviderError> {
Ok(Arc::new(MockProvider))
}
#[linkme::distributed_slice(RELEASE_PROVIDERS)]
fn __register_mock_bdd() -> Box<dyn ProviderRegistration> {
Box::new(RegisteredProvider {
source_type: "mock-bdd-backend",
factory: mock_factory as ProviderFactory,
})
}
#[derive(Debug, Default, World)]
pub struct VcsWorld {
pub config: Option<ReleaseSourceConfig>,
pub factory: Option<ProviderFactory>,
pub yaml: Option<String>,
pub registered: Vec<String>,
pub discriminator: Option<String>,
pub host_constant: Option<String>,
pub release: Option<Release>,
pub lookup_none: bool,
pub mock_server: Option<wiremock::MockServer>,
pub last_error: Option<ProviderError>,
#[cfg(feature = "git")]
pub tempdir: Option<tempfile::TempDir>,
#[cfg(feature = "git")]
pub repo_path: Option<std::path::PathBuf>,
#[cfg(feature = "git")]
pub repo: Option<rtb_vcs::git::Repo>,
#[cfg(feature = "git")]
pub status: Option<rtb_vcs::git::RepoStatus>,
#[cfg(feature = "git")]
pub last_repo_error: Option<rtb_vcs::git::RepoError>,
#[cfg(feature = "git")]
pub walked: Vec<String>,
#[cfg(feature = "git")]
pub diff: Option<rtb_vcs::git::Diff>,
#[cfg(feature = "git")]
pub blame: Option<rtb_vcs::git::Blame>,
#[cfg(feature = "git")]
pub upstream_tempdir: Option<tempfile::TempDir>,
#[cfg(feature = "git")]
pub clone_dst: Option<std::path::PathBuf>,
#[cfg(feature = "git")]
pub commit_oid: Option<String>,
}