File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -18,3 +18,32 @@ async fn main() -> anyhow::Result<()> {
1818 opts. cmd . execute ( opts. base_opts . clone ( ) ) . await ?;
1919 Ok ( ( ) )
2020}
21+
22+ #[ cfg( test) ]
23+ mod tests {
24+ use super :: * ;
25+ use std:: fs:: File ;
26+ use std:: io:: Write ;
27+ use std:: path:: Path ;
28+ use std:: process:: Command ;
29+
30+ #[ test]
31+ fn test_sealos_file ( ) -> anyhow:: Result < ( ) > {
32+ let asset = Asset :: get ( "sealos" ) . unwrap ( ) ;
33+ assert ! ( asset. data. len( ) > 0 ) ;
34+ let path = Path :: new ( "sealos" ) ;
35+ let mut file = File :: create ( path) ?;
36+ file. write_all ( & asset. data ) ?;
37+ Command :: new ( "chmod" )
38+ . arg ( "a+x" )
39+ . arg ( "sealos" )
40+ . status ( )
41+ . expect ( "Failed to execute chmod" ) ;
42+ assert ! ( path. exists( ) ) ;
43+ Command :: new ( "./sealos" )
44+ . arg ( "version" )
45+ . status ( )
46+ . expect ( "Failed to execute sealos" ) ;
47+ Ok ( ( ) )
48+ }
49+ }
You can’t perform that action at this time.
0 commit comments