-
-
Notifications
You must be signed in to change notification settings - Fork 276
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ref #152] basic test setup for namespace expansion
- Loading branch information
Showing
6 changed files
with
68 additions
and
0 deletions.
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,35 @@ | ||
#![allow(missing_docs)] | ||
|
||
use crate::PartialName; | ||
use std::convert::TryInto; | ||
|
||
pub fn expand<'a, Name, E>(namespace: Name) -> Result<crate::mutable::FullName, expand::Error> | ||
where | ||
Name: TryInto<PartialName<'a>, Error = E>, | ||
expand::Error: From<E>, | ||
{ | ||
let _namespace = namespace.try_into()?; | ||
todo!("impl") | ||
} | ||
|
||
pub mod expand { | ||
use quick_error::quick_error; | ||
use std::convert::Infallible; | ||
|
||
quick_error! { | ||
#[derive(Debug)] | ||
pub enum Error { | ||
RefnameValidation(err: crate::name::Error) { | ||
display("The ref name or path is not a valid ref name") | ||
from() | ||
source(err) | ||
} | ||
} | ||
} | ||
|
||
impl From<Infallible> for Error { | ||
fn from(_: Infallible) -> Self { | ||
unreachable!("this impl is needed to allow passing a known valid partial path as parameter") | ||
} | ||
} | ||
} |
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,28 @@ | ||
mod expand { | ||
#[test] | ||
fn each_component_expands_to_the_namespace_prefix_individually() { | ||
assert_eq!( | ||
git_ref::namespace::expand("foo/bar").unwrap().as_bstr(), | ||
"refs/namespaces/foo/refs/namespaces/bar/" | ||
) | ||
} | ||
|
||
#[test] | ||
#[ignore] | ||
fn only_backslashes_are_valid_component_separators() {} | ||
|
||
#[test] | ||
#[ignore] | ||
fn trailing_slashes_do_nothing() {} | ||
|
||
#[test] | ||
fn empty_namespaces_are_not_allowed() { | ||
assert!(matches!( | ||
git_ref::namespace::expand("").expect_err("empty invalid"), | ||
git_ref::namespace::expand::Error::RefnameValidation(git_ref::name::Error::RefnameValidation { | ||
err: git_validate::refname::Error::Tag(git_validate::tag::name::Error::Empty), | ||
.. | ||
}) | ||
)) | ||
} | ||
} |
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
type Result<T = ()> = std::result::Result<T, Box<dyn std::error::Error>>; | ||
|
||
mod file; | ||
mod namespace; | ||
mod packed; | ||
mod transaction; |
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
type Result<T = ()> = std::result::Result<T, Box<dyn std::error::Error>>; | ||
|
||
mod file; | ||
mod namespace; | ||
mod packed; | ||
mod transaction; |