Skip to content

Commit 50596c4

Browse files
committed
testutils: allow passing TestRepoBackend to TestWorkspace too
1 parent c6cf9d5 commit 50596c4

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

lib/testutils/src/lib.rs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,16 +145,25 @@ pub struct TestWorkspace {
145145

146146
impl TestWorkspace {
147147
pub fn init(settings: &UserSettings, use_git: bool) -> Self {
148+
let backend = if use_git {
149+
TestRepoBackend::Git
150+
} else {
151+
TestRepoBackend::Local
152+
};
153+
Self::init_with_backend(settings, backend)
154+
}
155+
156+
pub fn init_with_backend(settings: &UserSettings, backend: TestRepoBackend) -> Self {
148157
let temp_dir = new_temp_dir();
149158

150159
let workspace_root = temp_dir.path().join("repo");
151160
fs::create_dir(&workspace_root).unwrap();
152161

153-
let (workspace, repo) = if use_git {
154-
Workspace::init_internal_git(settings, &workspace_root).unwrap()
155-
} else {
156-
Workspace::init_local(settings, &workspace_root).unwrap()
157-
};
162+
let (workspace, repo) =
163+
Workspace::init_with_backend(settings, &workspace_root, |store_path| {
164+
backend.init_backend(store_path)
165+
})
166+
.unwrap();
158167

159168
Self {
160169
temp_dir,

0 commit comments

Comments
 (0)