Skip to content

Commit

Permalink
feat(main): add cache cmd for rust
Browse files Browse the repository at this point in the history
  • Loading branch information
cuisongliu committed Dec 26, 2024
1 parent 0300b26 commit 9243b4b
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,32 @@ async fn main() -> anyhow::Result<()> {
opts.cmd.execute(opts.base_opts.clone()).await?;
Ok(())
}

#[cfg(test)]
mod tests {
use super::*;
use std::fs::File;
use std::io::Write;
use std::path::Path;
use std::process::Command;

#[test]
fn test_sealos_file() -> anyhow::Result<()> {
let asset = Asset::get("sealos").unwrap();
assert!(asset.data.len() > 0);
let path = Path::new("sealos");
let mut file = File::create(path)?;
file.write_all(&asset.data)?;
Command::new("chmod")
.arg("a+x")
.arg("sealos")
.status()
.expect("Failed to execute chmod");
assert!(path.exists());
Command::new("./sealos")
.arg("version")
.status()
.expect("Failed to execute sealos");
Ok(())
}
}

0 comments on commit 9243b4b

Please sign in to comment.