aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/tests/repository
diff options
context:
space:
mode:
Diffstat (limited to 'crates/shirabe/tests/repository')
-rw-r--r--crates/shirabe/tests/repository/artifact_repository_test.rs12
-rw-r--r--crates/shirabe/tests/repository/filter_repository_test.rs13
-rw-r--r--crates/shirabe/tests/repository/repository_manager_test.rs43
-rw-r--r--crates/shirabe/tests/repository/vcs/forgejo_driver_test.rs92
-rw-r--r--crates/shirabe/tests/repository/vcs/fossil_driver_test.rs45
-rw-r--r--crates/shirabe/tests/repository/vcs/git_bitbucket_driver_test.rs94
-rw-r--r--crates/shirabe/tests/repository/vcs/git_driver_test.rs65
-rw-r--r--crates/shirabe/tests/repository/vcs/github_driver_test.rs66
-rw-r--r--crates/shirabe/tests/repository/vcs/hg_driver_test.rs57
-rw-r--r--crates/shirabe/tests/repository/vcs/perforce_driver_test.rs190
-rw-r--r--crates/shirabe/tests/repository/vcs/svn_driver_test.rs48
-rw-r--r--crates/shirabe/tests/repository/vcs_repository_test.rs45
12 files changed, 763 insertions, 7 deletions
diff --git a/crates/shirabe/tests/repository/artifact_repository_test.rs b/crates/shirabe/tests/repository/artifact_repository_test.rs
index 58cb888..5e70650 100644
--- a/crates/shirabe/tests/repository/artifact_repository_test.rs
+++ b/crates/shirabe/tests/repository/artifact_repository_test.rs
@@ -3,20 +3,32 @@
// ArtifactRepository::getPackages scans the fixture directory and opens each archive via
// ZipArchive / PharData, both of which are todo!() in the php-shim.
+use shirabe_php_shim::extension_loaded;
+
+fn set_up() {
+ if !extension_loaded("zip") {
+ // markTestSkipped('You need the zip extension to run this test.')
+ todo!()
+ }
+}
+
#[test]
#[ignore = "ArtifactRepository reads archives via ZipArchive/PharData, which are todo!() in the php-shim"]
fn test_extracts_configs_from_zip_archives() {
+ set_up();
todo!()
}
#[test]
#[ignore = "ArtifactRepository reads archives via ZipArchive/PharData, which are todo!() in the php-shim"]
fn test_absolute_repo_url_creates_absolute_url_packages() {
+ set_up();
todo!()
}
#[test]
#[ignore = "ArtifactRepository reads archives via ZipArchive/PharData, which are todo!() in the php-shim"]
fn test_relative_repo_url_creates_relative_url_packages() {
+ set_up();
todo!()
}
diff --git a/crates/shirabe/tests/repository/filter_repository_test.rs b/crates/shirabe/tests/repository/filter_repository_test.rs
index 1074fb4..a244f52 100644
--- a/crates/shirabe/tests/repository/filter_repository_test.rs
+++ b/crates/shirabe/tests/repository/filter_repository_test.rs
@@ -10,8 +10,7 @@ use shirabe_semver::constraint::{AnyConstraint, MatchAllConstraint};
use crate::test_case::get_package;
-/// ref: FilterRepositoryTest::setUp
-fn array_repo() -> RepositoryInterfaceHandle {
+fn set_up() -> RepositoryInterfaceHandle {
let repo = ArrayRepository::new(vec![
get_package("foo/aaa", "1.0.0"),
get_package("foo/bbb", "1.0.0"),
@@ -86,7 +85,7 @@ fn test_repo_matching() {
];
for (expected, cfg) in cases {
- let mut repo = FilterRepository::new(array_repo(), cfg).unwrap();
+ let mut repo = FilterRepository::new(set_up(), cfg).unwrap();
let packages = repo.get_packages().unwrap();
let names: Vec<String> = packages.iter().map(|p| p.get_name()).collect();
@@ -97,12 +96,12 @@ fn test_repo_matching() {
#[test]
fn test_both_filters_disallowed() {
- assert!(FilterRepository::new(array_repo(), config(Some(&[]), Some(&[]))).is_err());
+ assert!(FilterRepository::new(set_up(), config(Some(&[]), Some(&[]))).is_err());
}
#[test]
fn test_security_advisories_disabled_in_child() {
- let mut repo = FilterRepository::new(array_repo(), config(Some(&["foo/*"]), None)).unwrap();
+ let mut repo = FilterRepository::new(set_up(), config(Some(&["foo/*"]), None)).unwrap();
assert!(!repo.has_security_advisories().unwrap());
@@ -116,7 +115,7 @@ fn test_security_advisories_disabled_in_child() {
#[test]
fn test_canonical_default_true() {
- let mut repo = FilterRepository::new(array_repo(), config(None, None)).unwrap();
+ let mut repo = FilterRepository::new(set_up(), config(None, None)).unwrap();
let mut map: IndexMap<String, Option<AnyConstraint>> = IndexMap::new();
map.insert("foo/aaa".to_string(), Some(match_all()));
@@ -133,7 +132,7 @@ fn test_non_canonical() {
use shirabe_php_shim::PhpMixed;
let mut cfg: IndexMap<String, PhpMixed> = IndexMap::new();
cfg.insert("canonical".to_string(), PhpMixed::Bool(false));
- let mut repo = FilterRepository::new(array_repo(), cfg).unwrap();
+ let mut repo = FilterRepository::new(set_up(), cfg).unwrap();
let mut map: IndexMap<String, Option<AnyConstraint>> = IndexMap::new();
map.insert("foo/aaa".to_string(), Some(match_all()));
diff --git a/crates/shirabe/tests/repository/repository_manager_test.rs b/crates/shirabe/tests/repository/repository_manager_test.rs
index 60deb7e..dec018a 100644
--- a/crates/shirabe/tests/repository/repository_manager_test.rs
+++ b/crates/shirabe/tests/repository/repository_manager_test.rs
@@ -4,26 +4,69 @@
// curl_multi_init, todo!()) with a mocked IO/Config/EventDispatcher and exercise repo
// creation/prepending/wrapping.
+use shirabe::util::filesystem::Filesystem;
+use tempfile::TempDir;
+
+struct SetUp {
+ tmpdir: TempDir,
+}
+
+fn set_up() -> SetUp {
+ let tmpdir = TempDir::new().unwrap();
+ SetUp { tmpdir }
+}
+
+fn tear_down(tmpdir: &std::path::Path) {
+ if tmpdir.is_dir() {
+ let mut fs = Filesystem::new(None);
+ fs.remove_directory(tmpdir).unwrap();
+ }
+}
+
+struct TearDown {
+ tmpdir: std::path::PathBuf,
+}
+
+impl TearDown {
+ fn new(tmpdir: std::path::PathBuf) -> Self {
+ TearDown { tmpdir }
+ }
+}
+
+impl Drop for TearDown {
+ fn drop(&mut self) {
+ tear_down(&self.tmpdir);
+ }
+}
+
#[test]
#[ignore = "RepositoryManager::new builds an HttpDownloader (curl_multi_init todo!()) and mocks IO/Config"]
fn test_prepend() {
+ let SetUp { tmpdir } = set_up();
+ let _tear_down = TearDown::new(tmpdir.path().to_path_buf());
todo!()
}
#[test]
#[ignore = "RepositoryManager::new builds an HttpDownloader (curl_multi_init todo!()) and mocks IO/Config"]
fn test_repo_creation() {
+ let SetUp { tmpdir } = set_up();
+ let _tear_down = TearDown::new(tmpdir.path().to_path_buf());
todo!()
}
#[test]
#[ignore = "RepositoryManager::new builds an HttpDownloader (curl_multi_init todo!()) and mocks IO/Config"]
fn test_invalid_repo_creation_throws() {
+ let SetUp { tmpdir } = set_up();
+ let _tear_down = TearDown::new(tmpdir.path().to_path_buf());
todo!()
}
#[test]
#[ignore = "RepositoryManager::new builds an HttpDownloader (curl_multi_init todo!()) and mocks IO/Config"]
fn test_filter_repo_wrapping() {
+ let SetUp { tmpdir } = set_up();
+ let _tear_down = TearDown::new(tmpdir.path().to_path_buf());
todo!()
}
diff --git a/crates/shirabe/tests/repository/vcs/forgejo_driver_test.rs b/crates/shirabe/tests/repository/vcs/forgejo_driver_test.rs
index f488182..a67bce3 100644
--- a/crates/shirabe/tests/repository/vcs/forgejo_driver_test.rs
+++ b/crates/shirabe/tests/repository/vcs/forgejo_driver_test.rs
@@ -3,10 +3,70 @@
use std::cell::RefCell;
use std::rc::Rc;
+use indexmap::IndexMap;
use shirabe::config::Config;
use shirabe::io::IOInterface;
use shirabe::io::null_io::NullIO;
use shirabe::repository::vcs::ForgejoDriver;
+use shirabe::util::filesystem::Filesystem;
+use shirabe_php_shim::PhpMixed;
+use tempfile::TempDir;
+
+struct SetUp {
+ home: TempDir,
+ config: Config,
+ // The IOInterface and HttpDownloader mocks are not ported.
+ io: (),
+ http_downloader: (),
+}
+
+fn set_up() -> SetUp {
+ let home = TempDir::new().unwrap();
+ let mut config = Config::new(true, None);
+ let mut top: IndexMap<String, PhpMixed> = IndexMap::new();
+ let mut config_section: IndexMap<String, PhpMixed> = IndexMap::new();
+ config_section.insert(
+ "home".to_string(),
+ PhpMixed::String(home.path().to_string_lossy().into_owned()),
+ );
+ config_section.insert(
+ "forgejo-domains".to_string(),
+ PhpMixed::List(vec![PhpMixed::String("codeberg.org".to_string())]),
+ );
+ top.insert("config".to_string(), PhpMixed::Array(config_section));
+ config.merge(&top, Config::SOURCE_UNKNOWN);
+
+ let io = ();
+ let http_downloader = ();
+
+ SetUp {
+ home,
+ config,
+ io,
+ http_downloader,
+ }
+}
+
+fn tear_down(home: &std::path::Path) {
+ let mut fs = Filesystem::new(None);
+ fs.remove_directory(home).unwrap();
+}
+
+struct TearDown {
+ home: std::path::PathBuf,
+}
+
+impl TearDown {
+ fn new(home: std::path::PathBuf) -> Self {
+ TearDown { home }
+ }
+}
+
+impl Drop for TearDown {
+ fn drop(&mut self) {
+ tear_down(&self.home);
+ }
+}
fn supports_provider() -> Vec<(bool, &'static str)> {
vec![
@@ -35,23 +95,55 @@ fn test_supports() {
#[test]
#[ignore = "constructs a ForgejoDriver and mocks the HttpDownloader (curl_multi_init todo!())"]
fn test_public_repository() {
+ let SetUp {
+ home,
+ config,
+ io,
+ http_downloader,
+ } = set_up();
+ let _tear_down = TearDown::new(home.path().to_path_buf());
+ let _ = (&config, &io, &http_downloader);
todo!()
}
#[test]
#[ignore = "constructs a ForgejoDriver and mocks the HttpDownloader (curl_multi_init todo!())"]
fn test_get_branches() {
+ let SetUp {
+ home,
+ config,
+ io,
+ http_downloader,
+ } = set_up();
+ let _tear_down = TearDown::new(home.path().to_path_buf());
+ let _ = (&config, &io, &http_downloader);
todo!()
}
#[test]
#[ignore = "constructs a ForgejoDriver and mocks the HttpDownloader (curl_multi_init todo!())"]
fn test_get_tags() {
+ let SetUp {
+ home,
+ config,
+ io,
+ http_downloader,
+ } = set_up();
+ let _tear_down = TearDown::new(home.path().to_path_buf());
+ let _ = (&config, &io, &http_downloader);
todo!()
}
#[test]
#[ignore = "constructs a ForgejoDriver and mocks the HttpDownloader (curl_multi_init todo!())"]
fn test_get_empty_file_content() {
+ let SetUp {
+ home,
+ config,
+ io,
+ http_downloader,
+ } = set_up();
+ let _tear_down = TearDown::new(home.path().to_path_buf());
+ let _ = (&config, &io, &http_downloader);
todo!()
}
diff --git a/crates/shirabe/tests/repository/vcs/fossil_driver_test.rs b/crates/shirabe/tests/repository/vcs/fossil_driver_test.rs
index e677b3d..a3986c2 100644
--- a/crates/shirabe/tests/repository/vcs/fossil_driver_test.rs
+++ b/crates/shirabe/tests/repository/vcs/fossil_driver_test.rs
@@ -3,10 +3,55 @@
use std::cell::RefCell;
use std::rc::Rc;
+use indexmap::IndexMap;
use shirabe::config::Config;
use shirabe::io::IOInterface;
use shirabe::io::null_io::NullIO;
use shirabe::repository::vcs::FossilDriver;
+use shirabe::util::filesystem::Filesystem;
+use shirabe_php_shim::PhpMixed;
+use tempfile::TempDir;
+
+struct SetUp {
+ home: TempDir,
+ config: Config,
+}
+
+fn set_up() -> SetUp {
+ let home = TempDir::new().unwrap();
+ let mut config = Config::new(true, None);
+ let mut top: IndexMap<String, PhpMixed> = IndexMap::new();
+ let mut config_section: IndexMap<String, PhpMixed> = IndexMap::new();
+ config_section.insert(
+ "home".to_string(),
+ PhpMixed::String(home.path().to_string_lossy().into_owned()),
+ );
+ top.insert("config".to_string(), PhpMixed::Array(config_section));
+ config.merge(&top, Config::SOURCE_UNKNOWN);
+
+ SetUp { home, config }
+}
+
+fn tear_down(home: &std::path::Path) {
+ let mut fs = Filesystem::new(None);
+ fs.remove_directory(home).unwrap();
+}
+
+struct TearDown {
+ home: std::path::PathBuf,
+}
+
+impl TearDown {
+ fn new(home: std::path::PathBuf) -> Self {
+ TearDown { home }
+ }
+}
+
+impl Drop for TearDown {
+ fn drop(&mut self) {
+ tear_down(&self.home);
+ }
+}
fn support_provider() -> Vec<(&'static str, bool)> {
vec![
diff --git a/crates/shirabe/tests/repository/vcs/git_bitbucket_driver_test.rs b/crates/shirabe/tests/repository/vcs/git_bitbucket_driver_test.rs
index e48c609..b6759b5 100644
--- a/crates/shirabe/tests/repository/vcs/git_bitbucket_driver_test.rs
+++ b/crates/shirabe/tests/repository/vcs/git_bitbucket_driver_test.rs
@@ -3,10 +3,69 @@
use std::cell::RefCell;
use std::rc::Rc;
+use indexmap::IndexMap;
use shirabe::config::Config;
use shirabe::io::IOInterface;
use shirabe::io::null_io::NullIO;
use shirabe::repository::vcs::GitBitbucketDriver;
+use shirabe::util::filesystem::Filesystem;
+use shirabe_php_shim::PhpMixed;
+use tempfile::TempDir;
+
+struct SetUp {
+ home: TempDir,
+ config: Config,
+ // The IOInterface mock and the HttpDownloaderMock are not ported.
+ io: (),
+ http_downloader: (),
+}
+
+fn set_up() -> SetUp {
+ // The IOInterface mock is created via PHPUnit's getMockBuilder, which is not ported.
+ let io: () = todo!();
+
+ let home = TempDir::new().unwrap();
+ let mut config = Config::new(true, None);
+ let mut top: IndexMap<String, PhpMixed> = IndexMap::new();
+ let mut config_section: IndexMap<String, PhpMixed> = IndexMap::new();
+ config_section.insert(
+ "home".to_string(),
+ PhpMixed::String(home.path().to_string_lossy().into_owned()),
+ );
+ top.insert("config".to_string(), PhpMixed::Array(config_section));
+ config.merge(&top, Config::SOURCE_UNKNOWN);
+
+ // The HttpDownloaderMock is created via getHttpDownloaderMock, which is not ported.
+ let http_downloader: () = todo!();
+
+ SetUp {
+ home,
+ config,
+ io,
+ http_downloader,
+ }
+}
+
+fn tear_down(home: &std::path::Path) {
+ let mut fs = Filesystem::new(None);
+ fs.remove_directory(home).unwrap();
+}
+
+struct TearDown {
+ home: std::path::PathBuf,
+}
+
+impl TearDown {
+ fn new(home: std::path::PathBuf) -> Self {
+ TearDown { home }
+ }
+}
+
+impl Drop for TearDown {
+ fn drop(&mut self) {
+ tear_down(&self.home);
+ }
+}
#[test]
fn test_supports() {
@@ -46,29 +105,64 @@ fn test_supports() {
#[test]
#[ignore = "constructs a GitBitbucketDriver and mocks the HttpDownloader (curl_multi_init todo!())"]
fn test_get_root_identifier_wrong_scm_type() {
+ let SetUp {
+ home,
+ config: _,
+ io: _,
+ http_downloader: _,
+ } = set_up();
+ let _tear_down = TearDown::new(home.path().to_path_buf());
todo!()
}
#[test]
#[ignore = "constructs a GitBitbucketDriver and mocks the HttpDownloader (curl_multi_init todo!())"]
fn test_driver() {
+ let SetUp {
+ home,
+ config: _,
+ io: _,
+ http_downloader: _,
+ } = set_up();
+ let _tear_down = TearDown::new(home.path().to_path_buf());
todo!()
}
#[test]
#[ignore = "constructs a GitBitbucketDriver and mocks the HttpDownloader (curl_multi_init todo!())"]
fn test_get_params() {
+ let SetUp {
+ home,
+ config: _,
+ io: _,
+ http_downloader: _,
+ } = set_up();
+ let _tear_down = TearDown::new(home.path().to_path_buf());
todo!()
}
#[test]
#[ignore = "constructs a GitBitbucketDriver and mocks the HttpDownloader (curl_multi_init todo!())"]
fn test_initialize_invalid_repository_url() {
+ let SetUp {
+ home,
+ config: _,
+ io: _,
+ http_downloader: _,
+ } = set_up();
+ let _tear_down = TearDown::new(home.path().to_path_buf());
todo!()
}
#[test]
#[ignore = "constructs a GitBitbucketDriver and mocks the HttpDownloader (curl_multi_init todo!())"]
fn test_invalid_support_data() {
+ let SetUp {
+ home,
+ config: _,
+ io: _,
+ http_downloader: _,
+ } = set_up();
+ let _tear_down = TearDown::new(home.path().to_path_buf());
todo!()
}
diff --git a/crates/shirabe/tests/repository/vcs/git_driver_test.rs b/crates/shirabe/tests/repository/vcs/git_driver_test.rs
index 85c9f0b..c36470c 100644
--- a/crates/shirabe/tests/repository/vcs/git_driver_test.rs
+++ b/crates/shirabe/tests/repository/vcs/git_driver_test.rs
@@ -4,11 +4,76 @@
// that reaches curl_multi_init, todo!()) to feed git command output; mocking is not
// available here.
+use indexmap::IndexMap;
+use shirabe::config::Config;
+use shirabe::util::filesystem::Filesystem;
+use shirabe::util::platform::Platform;
+use shirabe_php_shim::PhpMixed;
+use tempfile::TempDir;
+
+struct SetUp {
+ home: TempDir,
+ config: Config,
+ network_env: Option<String>,
+}
+
+fn set_up() -> SetUp {
+ let home = TempDir::new().unwrap();
+ let mut config = Config::new(true, None);
+ let mut top: IndexMap<String, PhpMixed> = IndexMap::new();
+ let mut config_section: IndexMap<String, PhpMixed> = IndexMap::new();
+ config_section.insert(
+ "home".to_string(),
+ PhpMixed::String(home.path().to_string_lossy().into_owned()),
+ );
+ top.insert("config".to_string(), PhpMixed::Array(config_section));
+ config.merge(&top, Config::SOURCE_UNKNOWN);
+ let network_env = Platform::get_env("COMPOSER_DISABLE_NETWORK");
+
+ SetUp {
+ home,
+ config,
+ network_env,
+ }
+}
+
+fn tear_down(home: &std::path::Path, network_env: &Option<String>) {
+ let mut fs = Filesystem::new(None);
+ fs.remove_directory(home).unwrap();
+ match network_env {
+ None => Platform::clear_env("COMPOSER_DISABLE_NETWORK"),
+ Some(network_env) => Platform::put_env("COMPOSER_DISABLE_NETWORK", network_env),
+ }
+}
+
+struct TearDown {
+ home: std::path::PathBuf,
+ network_env: Option<String>,
+}
+
+impl TearDown {
+ fn new(home: std::path::PathBuf, network_env: Option<String>) -> Self {
+ TearDown { home, network_env }
+ }
+}
+
+impl Drop for TearDown {
+ fn drop(&mut self) {
+ tear_down(&self.home, &self.network_env);
+ }
+}
+
macro_rules! git_stub {
($name:ident) => {
#[test]
#[ignore = "constructs a GitDriver and mocks a ProcessExecutor/HttpDownloader (curl_multi_init todo!())"]
fn $name() {
+ let SetUp {
+ home,
+ config: _,
+ network_env,
+ } = set_up();
+ let _tear_down = TearDown::new(home.path().to_path_buf(), network_env);
todo!()
}
};
diff --git a/crates/shirabe/tests/repository/vcs/github_driver_test.rs b/crates/shirabe/tests/repository/vcs/github_driver_test.rs
index d0067d5..3e97599 100644
--- a/crates/shirabe/tests/repository/vcs/github_driver_test.rs
+++ b/crates/shirabe/tests/repository/vcs/github_driver_test.rs
@@ -3,10 +3,55 @@
use std::cell::RefCell;
use std::rc::Rc;
+use indexmap::IndexMap;
use shirabe::config::Config;
use shirabe::io::IOInterface;
use shirabe::io::null_io::NullIO;
use shirabe::repository::vcs::GitHubDriver;
+use shirabe::util::filesystem::Filesystem;
+use shirabe_php_shim::PhpMixed;
+use tempfile::TempDir;
+
+struct SetUp {
+ home: TempDir,
+ config: Config,
+}
+
+fn set_up() -> SetUp {
+ let home = TempDir::new().unwrap();
+ let mut config = Config::new(true, None);
+ let mut top: IndexMap<String, PhpMixed> = IndexMap::new();
+ let mut config_section: IndexMap<String, PhpMixed> = IndexMap::new();
+ config_section.insert(
+ "home".to_string(),
+ PhpMixed::String(home.path().to_string_lossy().into_owned()),
+ );
+ top.insert("config".to_string(), PhpMixed::Array(config_section));
+ config.merge(&top, Config::SOURCE_UNKNOWN);
+
+ SetUp { home, config }
+}
+
+fn tear_down(home: &std::path::Path) {
+ let mut fs = Filesystem::new(None);
+ fs.remove_directory(home).unwrap();
+}
+
+struct TearDown {
+ home: std::path::PathBuf,
+}
+
+impl TearDown {
+ fn new(home: std::path::PathBuf) -> Self {
+ TearDown { home }
+ }
+}
+
+impl Drop for TearDown {
+ fn drop(&mut self) {
+ tear_down(&self.home);
+ }
+}
fn supports_provider() -> Vec<(bool, &'static str)> {
vec![
@@ -21,6 +66,9 @@ fn supports_provider() -> Vec<(bool, &'static str)> {
#[test]
#[ignore = "GitHubDriver::supports reaches non-strict in_array, which is todo!() in the php-shim"]
fn test_supports() {
+ let SetUp { home, config: _ } = set_up();
+ let _tear_down = TearDown::new(home.path().to_path_buf());
+
for (expected, repo_url) in supports_provider() {
let io: Rc<RefCell<dyn IOInterface>> = Rc::new(RefCell::new(NullIO::new()));
let config = Rc::new(RefCell::new(Config::new(true, None)));
@@ -38,53 +86,71 @@ fn test_supports() {
#[test]
#[ignore = "constructs a GitHubDriver and mocks the HttpDownloader/IO (curl_multi_init todo!())"]
fn test_private_repository() {
+ let SetUp { home, config: _ } = set_up();
+ let _tear_down = TearDown::new(home.path().to_path_buf());
todo!()
}
#[test]
#[ignore = "constructs a GitHubDriver and mocks the HttpDownloader/IO (curl_multi_init todo!())"]
fn test_public_repository() {
+ let SetUp { home, config: _ } = set_up();
+ let _tear_down = TearDown::new(home.path().to_path_buf());
todo!()
}
#[test]
#[ignore = "constructs a GitHubDriver and mocks the HttpDownloader/IO (curl_multi_init todo!())"]
fn test_public_repository2() {
+ let SetUp { home, config: _ } = set_up();
+ let _tear_down = TearDown::new(home.path().to_path_buf());
todo!()
}
#[test]
#[ignore = "constructs a GitHubDriver and mocks the HttpDownloader/IO (curl_multi_init todo!())"]
fn test_invalid_support_data() {
+ let SetUp { home, config: _ } = set_up();
+ let _tear_down = TearDown::new(home.path().to_path_buf());
todo!()
}
#[test]
#[ignore = "constructs a GitHubDriver and mocks the HttpDownloader/IO (curl_multi_init todo!())"]
fn test_funding_format() {
+ let SetUp { home, config: _ } = set_up();
+ let _tear_down = TearDown::new(home.path().to_path_buf());
todo!()
}
#[test]
#[ignore = "constructs a GitHubDriver and mocks the HttpDownloader/IO (curl_multi_init todo!())"]
fn test_public_repository_archived() {
+ let SetUp { home, config: _ } = set_up();
+ let _tear_down = TearDown::new(home.path().to_path_buf());
todo!()
}
#[test]
#[ignore = "constructs a GitHubDriver and mocks the HttpDownloader/IO (curl_multi_init todo!())"]
fn test_private_repository_no_interaction() {
+ let SetUp { home, config: _ } = set_up();
+ let _tear_down = TearDown::new(home.path().to_path_buf());
todo!()
}
#[test]
#[ignore = "constructs a GitHubDriver and mocks the HttpDownloader/IO (curl_multi_init todo!())"]
fn test_initialize_invalid_repo_url() {
+ let SetUp { home, config: _ } = set_up();
+ let _tear_down = TearDown::new(home.path().to_path_buf());
todo!()
}
#[test]
#[ignore = "constructs a GitHubDriver and mocks the HttpDownloader/IO (curl_multi_init todo!())"]
fn test_get_empty_file_content() {
+ let SetUp { home, config: _ } = set_up();
+ let _tear_down = TearDown::new(home.path().to_path_buf());
todo!()
}
diff --git a/crates/shirabe/tests/repository/vcs/hg_driver_test.rs b/crates/shirabe/tests/repository/vcs/hg_driver_test.rs
index d7ff5c3..155d7ce 100644
--- a/crates/shirabe/tests/repository/vcs/hg_driver_test.rs
+++ b/crates/shirabe/tests/repository/vcs/hg_driver_test.rs
@@ -3,10 +3,58 @@
use std::cell::RefCell;
use std::rc::Rc;
+use indexmap::IndexMap;
use shirabe::config::Config;
use shirabe::io::IOInterface;
use shirabe::io::null_io::NullIO;
use shirabe::repository::vcs::HgDriver;
+use shirabe::util::filesystem::Filesystem;
+use shirabe_php_shim::PhpMixed;
+use tempfile::TempDir;
+
+struct SetUp {
+ home: TempDir,
+ config: Config,
+ // The IOInterface mock is not ported.
+ io: (),
+}
+
+fn set_up() -> SetUp {
+ let io = ();
+ let home = TempDir::new().unwrap();
+ let mut config = Config::new(true, None);
+ let mut top: IndexMap<String, PhpMixed> = IndexMap::new();
+ let mut config_section: IndexMap<String, PhpMixed> = IndexMap::new();
+ config_section.insert(
+ "home".to_string(),
+ PhpMixed::String(home.path().to_string_lossy().into_owned()),
+ );
+ top.insert("config".to_string(), PhpMixed::Array(config_section));
+ config.merge(&top, Config::SOURCE_UNKNOWN);
+
+ SetUp { home, config, io }
+}
+
+fn tear_down(home: &std::path::Path) {
+ let mut fs = Filesystem::new(None);
+ fs.remove_directory(home).unwrap();
+}
+
+struct TearDown {
+ home: std::path::PathBuf,
+}
+
+impl TearDown {
+ fn new(home: std::path::PathBuf) -> Self {
+ TearDown { home }
+ }
+}
+
+impl Drop for TearDown {
+ fn drop(&mut self) {
+ tear_down(&self.home);
+ }
+}
fn supports_data_provider() -> Vec<&'static str> {
vec![
@@ -34,17 +82,26 @@ fn test_supports() {
#[test]
#[ignore = "needs an HgDriver instance (HttpDownloader reaches curl_multi_init, todo!()) and a mocked ProcessExecutor"]
fn test_get_branches_filter_invalid_branch_names() {
+ let SetUp { home, config, io } = set_up();
+ let _tear_down = TearDown::new(home.path().to_path_buf());
+ let _ = (&config, &io);
todo!()
}
#[test]
#[ignore = "needs an HgDriver instance (HttpDownloader reaches curl_multi_init, todo!()) and a mocked ProcessExecutor"]
fn test_file_get_content_invalid_identifier() {
+ let SetUp { home, config, io } = set_up();
+ let _tear_down = TearDown::new(home.path().to_path_buf());
+ let _ = (&config, &io);
todo!()
}
#[test]
#[ignore = "needs an HgDriver instance (HttpDownloader reaches curl_multi_init, todo!()) and a mocked ProcessExecutor"]
fn test_get_change_date_invalid_identifier() {
+ let SetUp { home, config, io } = set_up();
+ let _tear_down = TearDown::new(home.path().to_path_buf());
+ let _ = (&config, &io);
todo!()
}
diff --git a/crates/shirabe/tests/repository/vcs/perforce_driver_test.rs b/crates/shirabe/tests/repository/vcs/perforce_driver_test.rs
index c8353de..1c28487 100644
--- a/crates/shirabe/tests/repository/vcs/perforce_driver_test.rs
+++ b/crates/shirabe/tests/repository/vcs/perforce_driver_test.rs
@@ -3,10 +3,100 @@
use std::cell::RefCell;
use std::rc::Rc;
+use indexmap::IndexMap;
use shirabe::config::Config;
use shirabe::io::IOInterface;
use shirabe::io::null_io::NullIO;
use shirabe::repository::vcs::PerforceDriver;
+use shirabe::util::filesystem::Filesystem;
+use shirabe_php_shim::PhpMixed;
+use tempfile::TempDir;
+
+const TEST_URL: &str = "TEST_PERFORCE_URL";
+const TEST_DEPOT: &str = "TEST_DEPOT_CONFIG";
+const TEST_BRANCH: &str = "TEST_BRANCH_CONFIG";
+
+struct SetUp {
+ test_path: TempDir,
+ config: Config,
+ repo_config: IndexMap<String, PhpMixed>,
+ // The IOInterface, ProcessExecutor, HttpDownloader and Perforce mocks, the
+ // driver instance and the reflection-based perforce override are not ported.
+ io: (),
+ process: (),
+ http_downloader: (),
+ perforce: (),
+ driver: (),
+}
+
+fn get_test_config(test_path: &std::path::Path) -> Config {
+ let mut config = Config::new(true, None);
+ let mut top: IndexMap<String, PhpMixed> = IndexMap::new();
+ let mut config_section: IndexMap<String, PhpMixed> = IndexMap::new();
+ config_section.insert(
+ "home".to_string(),
+ PhpMixed::String(test_path.to_string_lossy().into_owned()),
+ );
+ top.insert("config".to_string(), PhpMixed::Array(config_section));
+ config.merge(&top, Config::SOURCE_UNKNOWN);
+
+ config
+}
+
+fn set_up() -> SetUp {
+ let test_path = TempDir::new().unwrap();
+ let config = get_test_config(test_path.path());
+ let mut repo_config: IndexMap<String, PhpMixed> = IndexMap::new();
+ repo_config.insert("url".to_string(), PhpMixed::String(TEST_URL.to_string()));
+ repo_config.insert(
+ "depot".to_string(),
+ PhpMixed::String(TEST_DEPOT.to_string()),
+ );
+ repo_config.insert(
+ "branch".to_string(),
+ PhpMixed::String(TEST_BRANCH.to_string()),
+ );
+
+ let io = ();
+ let process = ();
+ let http_downloader = ();
+ let perforce = ();
+ // The driver construction and overrideDriverInternalPerforce (reflection) are not ported.
+ let driver = ();
+
+ SetUp {
+ test_path,
+ config,
+ repo_config,
+ io,
+ process,
+ http_downloader,
+ perforce,
+ driver,
+ }
+}
+
+fn tear_down(test_path: &std::path::Path) {
+ // cleanup directory under test path
+ let mut fs = Filesystem::new(None);
+ fs.remove_directory(test_path).unwrap();
+}
+
+struct TearDown {
+ test_path: std::path::PathBuf,
+}
+
+impl TearDown {
+ fn new(test_path: std::path::PathBuf) -> Self {
+ TearDown { test_path }
+ }
+}
+
+impl Drop for TearDown {
+ fn drop(&mut self) {
+ tear_down(&self.test_path);
+ }
+}
#[test]
fn test_supports_returns_false_no_deep_check() {
@@ -21,29 +111,129 @@ fn test_supports_returns_false_no_deep_check() {
#[test]
#[ignore = "mocks Perforce/repository/IO; mocking is not available"]
fn test_initialize_captures_variables_from_repo_config() {
+ let SetUp {
+ test_path,
+ config,
+ repo_config,
+ io,
+ process,
+ http_downloader,
+ perforce,
+ driver,
+ } = set_up();
+ let _tear_down = TearDown::new(test_path.path().to_path_buf());
+ let _ = (
+ &config,
+ &repo_config,
+ &io,
+ &process,
+ &http_downloader,
+ &perforce,
+ &driver,
+ );
todo!()
}
#[test]
#[ignore = "mocks Perforce/repository/IO; mocking is not available"]
fn test_initialize_logs_in_and_connects_client() {
+ let SetUp {
+ test_path,
+ config,
+ repo_config,
+ io,
+ process,
+ http_downloader,
+ perforce,
+ driver,
+ } = set_up();
+ let _tear_down = TearDown::new(test_path.path().to_path_buf());
+ let _ = (
+ &config,
+ &repo_config,
+ &io,
+ &process,
+ &http_downloader,
+ &perforce,
+ &driver,
+ );
todo!()
}
#[test]
#[ignore = "mocks Perforce/repository/IO; mocking is not available"]
fn test_has_composer_file_returns_false_on_no_composer_file() {
+ let SetUp {
+ test_path,
+ config,
+ repo_config,
+ io,
+ process,
+ http_downloader,
+ perforce,
+ driver,
+ } = set_up();
+ let _tear_down = TearDown::new(test_path.path().to_path_buf());
+ let _ = (
+ &config,
+ &repo_config,
+ &io,
+ &process,
+ &http_downloader,
+ &perforce,
+ &driver,
+ );
todo!()
}
#[test]
#[ignore = "mocks Perforce/repository/IO; mocking is not available"]
fn test_has_composer_file_returns_true_with_one_or_more_composer_files() {
+ let SetUp {
+ test_path,
+ config,
+ repo_config,
+ io,
+ process,
+ http_downloader,
+ perforce,
+ driver,
+ } = set_up();
+ let _tear_down = TearDown::new(test_path.path().to_path_buf());
+ let _ = (
+ &config,
+ &repo_config,
+ &io,
+ &process,
+ &http_downloader,
+ &perforce,
+ &driver,
+ );
todo!()
}
#[test]
#[ignore = "mocks Perforce/repository/IO; mocking is not available"]
fn test_cleanup() {
+ let SetUp {
+ test_path,
+ config,
+ repo_config,
+ io,
+ process,
+ http_downloader,
+ perforce,
+ driver,
+ } = set_up();
+ let _tear_down = TearDown::new(test_path.path().to_path_buf());
+ let _ = (
+ &config,
+ &repo_config,
+ &io,
+ &process,
+ &http_downloader,
+ &perforce,
+ &driver,
+ );
todo!()
}
diff --git a/crates/shirabe/tests/repository/vcs/svn_driver_test.rs b/crates/shirabe/tests/repository/vcs/svn_driver_test.rs
index 262f0c3..9625088 100644
--- a/crates/shirabe/tests/repository/vcs/svn_driver_test.rs
+++ b/crates/shirabe/tests/repository/vcs/svn_driver_test.rs
@@ -3,10 +3,55 @@
use std::cell::RefCell;
use std::rc::Rc;
+use indexmap::IndexMap;
use shirabe::config::Config;
use shirabe::io::IOInterface;
use shirabe::io::null_io::NullIO;
use shirabe::repository::vcs::SvnDriver;
+use shirabe::util::filesystem::Filesystem;
+use shirabe_php_shim::PhpMixed;
+use tempfile::TempDir;
+
+struct SetUp {
+ home: TempDir,
+ config: Config,
+}
+
+fn set_up() -> SetUp {
+ let home = TempDir::new().unwrap();
+ let mut config = Config::new(true, None);
+ let mut top: IndexMap<String, PhpMixed> = IndexMap::new();
+ let mut config_section: IndexMap<String, PhpMixed> = IndexMap::new();
+ config_section.insert(
+ "home".to_string(),
+ PhpMixed::String(home.path().to_string_lossy().into_owned()),
+ );
+ top.insert("config".to_string(), PhpMixed::Array(config_section));
+ config.merge(&top, Config::SOURCE_UNKNOWN);
+
+ SetUp { home, config }
+}
+
+fn tear_down(home: &std::path::Path) {
+ let mut fs = Filesystem::new(None);
+ fs.remove_directory(home).unwrap();
+}
+
+struct TearDown {
+ home: std::path::PathBuf,
+}
+
+impl TearDown {
+ fn new(home: std::path::PathBuf) -> Self {
+ TearDown { home }
+ }
+}
+
+impl Drop for TearDown {
+ fn drop(&mut self) {
+ tear_down(&self.home);
+ }
+}
fn support_provider() -> Vec<(&'static str, bool)> {
vec![
@@ -35,5 +80,8 @@ fn test_support() {
#[test]
#[ignore = "constructs an SvnDriver and mocks a ProcessExecutor for the svn invocation"]
fn test_wrong_credentials_in_url() {
+ let SetUp { home, config } = set_up();
+ let _tear_down = TearDown::new(home.path().to_path_buf());
+ let _ = &config;
todo!()
}
diff --git a/crates/shirabe/tests/repository/vcs_repository_test.rs b/crates/shirabe/tests/repository/vcs_repository_test.rs
index b9486fc..c687b3d 100644
--- a/crates/shirabe/tests/repository/vcs_repository_test.rs
+++ b/crates/shirabe/tests/repository/vcs_repository_test.rs
@@ -1,10 +1,55 @@
//! ref: composer/tests/Composer/Test/Repository/VcsRepositoryTest.php
+use shirabe::util::filesystem::Filesystem;
+
+struct SetUp {
+ composer_home: std::path::PathBuf,
+ git_repo: std::path::PathBuf,
+}
+
+fn set_up() -> SetUp {
+ // setUp lazily runs initialize(), which shells out to git to build a fixture repository
+ // on disk; the ExecutableFinder/ProcessExecutor-driven setup and the markTestSkipped
+ // skip path are not ported.
+ todo!()
+}
+
+fn tear_down(composer_home: &std::path::Path, git_repo: &std::path::Path) {
+ let mut fs = Filesystem::new(None);
+ fs.remove_directory(composer_home).unwrap();
+ fs.remove_directory(git_repo).unwrap();
+}
+
+struct TearDown {
+ composer_home: std::path::PathBuf,
+ git_repo: std::path::PathBuf,
+}
+
+impl TearDown {
+ fn new(composer_home: std::path::PathBuf, git_repo: std::path::PathBuf) -> Self {
+ TearDown {
+ composer_home,
+ git_repo,
+ }
+ }
+}
+
+impl Drop for TearDown {
+ fn drop(&mut self) {
+ tear_down(&self.composer_home, &self.git_repo);
+ }
+}
+
// testLoadVersions initialises a real git repository on disk and drives a VcsRepository over
// it, then asserts the loaded package versions; the git fixture setup and constraint parsing
// (look-around regex) are not ported.
#[test]
#[ignore = "not yet ported (initialises a git repo on disk and loads versions; constraint parsing uses a look-around regex)"]
fn test_load_versions() {
+ let SetUp {
+ composer_home,
+ git_repo,
+ } = set_up();
+ let _tear_down = TearDown::new(composer_home, git_repo);
todo!()
}