-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wip: refactor and functionnalities to find the runtime
- Loading branch information
Showing
15 changed files
with
519 additions
and
145 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,46 @@ | ||
use super::digest_source::DigestSource; | ||
use super::versionned_digest::Digest; | ||
use serde_json::Result; | ||
use serde_json::Value; | ||
type Json = Value; | ||
|
||
pub struct DigestJson {} | ||
|
||
impl DigestSource<Json> for DigestJson { | ||
fn load(src: Json) -> Result<Digest> { | ||
let digest: Digest = serde_json::from_str(&src.to_string())?; | ||
Ok(digest) | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod test_super { | ||
use super::*; | ||
use crate::{ | ||
digest::digest_v2, | ||
samples::{SAMPLE_V1, SAMPLE_V2}, | ||
}; | ||
use serde_json::json; | ||
|
||
#[test] | ||
fn test_v1() { | ||
let v1: Value = serde_json::from_str(SAMPLE_V1).unwrap(); | ||
let digest = DigestJson::load(json!({ "V1": v1 })).unwrap(); | ||
|
||
match digest { | ||
Digest::V1(v1) => assert!(v1.src == "git"), | ||
Digest::V2(v2) => assert!(v2.info.src == digest_v2::Source::Git), | ||
} | ||
} | ||
|
||
#[test] | ||
fn test_v2() { | ||
let v2: Value = serde_json::from_str(SAMPLE_V2).unwrap(); | ||
let digest = DigestJson::load(json!({ "V2": v2 })).unwrap(); | ||
|
||
match digest { | ||
Digest::V1(v1) => assert!(v1.src == "git"), | ||
Digest::V2(v2) => assert!(v2.info.src == digest_v2::Source::Git), | ||
} | ||
} | ||
} |
File renamed without changes.
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,11 @@ | ||
mod digest_json; | ||
mod digest_source; | ||
mod digest_v1; | ||
mod digest_v2; | ||
mod versionned_digest; | ||
|
||
pub use digest_json::*; | ||
pub use digest_source::*; | ||
pub use digest_v1::*; | ||
pub use digest_v2::*; | ||
pub use versionned_digest::*; |
Oops, something went wrong.