1- use anyhow :: Result ;
1+ #! [ warn ( clippy :: pedantic ) ]
22
3+ use anyhow:: Result ;
34#[ cfg( all( feature = "encoding" , feature = "decoding" ) ) ]
45fn main ( ) -> Result < ( ) > {
56 use std:: path:: absolute;
67 use std:: { fs, path:: Path } ;
78
8- use lcas:: { build, create_repo, create_store, install_artifact} ;
9+ use lcas:: { RepoType , Store , build, create_repo, create_store, install_artifact} ;
910
1011 // Helper variables
1112 // `input_dir` is the artifact, likely produced by a build system etc. This is what we want to "transmit".
@@ -14,10 +15,19 @@ fn main() -> Result<()> {
1415 let repo_dir = absolute ( Path :: new ( "./example_repo" ) ) ?;
1516 // `store_dir` is the local path for the local store, and will be where the Store is placed, and each artifact inside.
1617 let store_dir = absolute ( Path :: new ( "./example_store" ) ) ?;
18+ // `store_dir` is the local path for the local store, and will be where the Store is placed, and each artifact inside.
19+ let cache_path = absolute ( Path :: new ( "./example_cache" ) ) ?;
20+
21+ let store = Store {
22+ kind : RepoType :: Local ,
23+ cache_path : cache_path,
24+ repo_path : repo_dir. to_string_lossy ( ) . to_string ( ) ,
25+ path : store_dir,
26+ } ;
1727
1828 // Create an example repo and a store, *locally*
1929 let _ = create_repo ( repo_dir. as_path ( ) ) ;
20- let _ = create_store ( & store_dir ) ;
30+ let _ = create_store ( & store ) ;
2131
2232 // Create an example artifact
2333 fs:: create_dir_all ( Path :: new ( "./example_dir/nested_dir/super_nested_dir" ) ) ?;
@@ -37,7 +47,7 @@ fn main() -> Result<()> {
3747 ) ?;
3848
3949 // Install the resulting manifest into an artifact in the `store_dir`
40- install_artifact ( & "generic" . to_string ( ) , store_dir . as_path ( ) , & repo_dir ) ?;
50+ install_artifact ( & "generic" . to_string ( ) , & store ) ?;
4151
4252 Ok ( ( ) )
4353}
@@ -51,6 +61,18 @@ fn main() -> Result<()> {
5161
5262#[ test]
5363#[ cfg( all( feature = "encoding" , feature = "decoding" ) ) ]
54- fn test_example ( ) {
55- main ( ) . unwrap ( ) ;
64+ fn test_example ( ) -> Result < ( ) > {
65+ let _ = remove_dir_all ( Path :: new ( "./example_dir" ) ) ;
66+ let _ = remove_dir_all ( Path :: new ( "./example_store" ) ) ;
67+ let _ = remove_dir_all ( Path :: new ( "./example_repo" ) ) ;
68+ let _ = remove_dir_all ( Path :: new ( "./example_cache" ) ) ;
69+
70+ let val = main ( ) ;
71+
72+ let _ = remove_dir_all ( Path :: new ( "./example_dir" ) ) ;
73+ let _ = remove_dir_all ( Path :: new ( "./example_store" ) ) ;
74+ let _ = remove_dir_all ( Path :: new ( "./example_repo" ) ) ;
75+ let _ = remove_dir_all ( Path :: new ( "./example_cache" ) ) ;
76+
77+ val
5678}
0 commit comments