From 50596c499e1fdd2abb8400dc753be4512587f6c0 Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Sun, 17 Sep 2023 15:48:21 -0700 Subject: [PATCH] testutils: allow passing `TestRepoBackend` to `TestWorkspace` too --- lib/testutils/src/lib.rs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/lib/testutils/src/lib.rs b/lib/testutils/src/lib.rs index 053b9e72a..44cfa7719 100644 --- a/lib/testutils/src/lib.rs +++ b/lib/testutils/src/lib.rs @@ -145,16 +145,25 @@ pub struct TestWorkspace { impl TestWorkspace { pub fn init(settings: &UserSettings, use_git: bool) -> Self { + let backend = if use_git { + TestRepoBackend::Git + } else { + TestRepoBackend::Local + }; + Self::init_with_backend(settings, backend) + } + + pub fn init_with_backend(settings: &UserSettings, backend: TestRepoBackend) -> Self { let temp_dir = new_temp_dir(); let workspace_root = temp_dir.path().join("repo"); fs::create_dir(&workspace_root).unwrap(); - let (workspace, repo) = if use_git { - Workspace::init_internal_git(settings, &workspace_root).unwrap() - } else { - Workspace::init_local(settings, &workspace_root).unwrap() - }; + let (workspace, repo) = + Workspace::init_with_backend(settings, &workspace_root, |store_path| { + backend.init_backend(store_path) + }) + .unwrap(); Self { temp_dir,