-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
159 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
use std::fmt; | ||
|
||
use assert_fs::TempDir; | ||
use url::Url; | ||
|
||
use crate::command::Scarb; | ||
|
||
pub struct LocalRegistry { | ||
#[allow(dead_code)] | ||
t: TempDir, | ||
url: String, | ||
} | ||
|
||
impl LocalRegistry { | ||
pub fn create() -> Self { | ||
let t = TempDir::new().unwrap(); | ||
let url = Url::from_directory_path(&t).unwrap().to_string(); | ||
Self { t, url } | ||
} | ||
|
||
pub fn publish(&mut self, f: impl FnOnce(&TempDir)) -> &mut Self { | ||
let t = TempDir::new().unwrap(); | ||
f(&t); | ||
Scarb::quick_snapbox() | ||
.arg("publish") | ||
.arg("--index") | ||
.arg(&self.url) | ||
.current_dir(&t) | ||
.assert() | ||
.success(); | ||
self | ||
} | ||
} | ||
|
||
impl fmt::Display for LocalRegistry { | ||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
fmt::Display::fmt(&self.url, f) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pub mod local; |