File tree Expand file tree Collapse file tree 1 file changed +45
-0
lines changed
Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Original file line number Diff line number Diff line change @@ -56,3 +56,48 @@ pub fn calc_build_hash(build_manifest_path: &Path, repo_path: &Path) -> Result<S
5656
5757 Ok ( hash. finalize ( ) . to_string ( ) )
5858}
59+
60+ #[ cfg( test) ]
61+ mod tests {
62+ use std:: path:: PathBuf ;
63+ use temp_dir:: TempDir ;
64+
65+ use super :: * ;
66+ use crate :: repo:: { Metadata , create_repo} ;
67+
68+ #[ test]
69+ fn test_build_hash_stability ( ) {
70+ let manifest = BuildManifest {
71+ id : "test_package" . into ( ) ,
72+ aliases : Vec :: new ( ) ,
73+ metadata : Metadata {
74+ description : None ,
75+ homepage_url : None ,
76+ title : None ,
77+ version : None ,
78+ license : None ,
79+ } ,
80+ commands : Vec :: new ( ) ,
81+ directory : PathBuf :: from ( "." ) ,
82+ edition : "2025" . into ( ) ,
83+ build_script : None ,
84+ post_script : None ,
85+ sources : None ,
86+ include : None ,
87+ sdks : None ,
88+ env : None ,
89+ } ;
90+
91+ let repo = TempDir :: new ( ) . unwrap ( ) ;
92+ create_repo ( repo. path ( ) , None ) . unwrap ( ) ;
93+
94+ let manifest_path = repo. path ( ) . join ( "build_manifest.yml" ) ;
95+
96+ fs:: write ( & manifest_path, serde_yaml:: to_string ( & manifest) . unwrap ( ) ) . unwrap ( ) ;
97+
98+ let known_hash = "680cec2b6b847e76d733fb435214b18ec2108e25b4dfc54695f5daa1e987ec8d" ;
99+ let calc_hash = calc_build_hash ( & manifest_path, repo. path ( ) ) . unwrap ( ) ;
100+
101+ assert_eq ! ( known_hash, calc_hash) ;
102+ }
103+ }
You can’t perform that action at this time.
0 commit comments