-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add basic tests for local registry (#798)
These tests depend on both #790 and #793, hence they come in separate PR. --- **Stack**: - #819 - #818 - #809 - #808 - #807 - #806 - #805 - #803 - #802 - #799 - #798 ⬅⚠️ *Part of a stack created by [spr](https://github.com/ejoffe/spr). Do not merge manually using the UI - doing so may have unexpected results.*
- Loading branch information
Showing
4 changed files
with
158 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,38 @@ | ||
use std::fmt; | ||
|
||
use assert_fs::TempDir; | ||
use url::Url; | ||
|
||
use crate::command::Scarb; | ||
|
||
pub struct LocalRegistry { | ||
pub t: TempDir, | ||
pub 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; |