diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml new file mode 100644 index 0000000..bb28dbe --- /dev/null +++ b/.github/workflows/rust.yml @@ -0,0 +1,24 @@ +name: Rust + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +env: + CARGO_TERM_COLOR: always + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Build + run: cargo build --verbose + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Run tests + run: cargo test --verbose diff --git a/src/pack.rs b/src/pack.rs index f14d62c..b85febd 100644 --- a/src/pack.rs +++ b/src/pack.rs @@ -88,9 +88,3 @@ pub fn pack_context(path: &str) -> PackageContext { pub fn pack_name(pack: &PackageContext) -> String { format!("{}-{}.scrate", pack.pack_info.name, pack.pack_info.version) } - -#[test] -fn test_cmd_cargo_package() { - let pac = pack_context("../cargo-crate"); - println!("{:#?}", pac); -} diff --git a/src/unpack.rs b/src/unpack.rs index 87a3372..e9fc7c5 100644 --- a/src/unpack.rs +++ b/src/unpack.rs @@ -1,8 +1,8 @@ use crate::utils::context::PackageContext; use crate::utils::pkcs::PKCS; -use std::fs; use std::path::PathBuf; use std::str::FromStr; +use std::{env, fs}; struct Unpacking { file_path: PathBuf, @@ -42,9 +42,9 @@ pub fn unpack_context(file_path: &str, cas_path: Vec) -> Result PKCS { let mut pkcs1 = PKCS::new(); pkcs1.load_from_file_writer( @@ -62,7 +62,18 @@ fn test_unpack() { let pack_context_decode = unpack_context("test/crate-spec.cra", vec!["test/root-ca.pem".to_string()]); - assert_eq!(pack_context_decode.as_ref().unwrap().pack_info, pack_context.pack_info); - assert_eq!(pack_context_decode.as_ref().unwrap().dep_infos, pack_context.dep_infos); - assert_eq!(pack_context_decode.unwrap().crate_binary, pack_context.crate_binary); + assert_eq!( + pack_context_decode.as_ref().unwrap().pack_info, + pack_context.pack_info + ); + assert_eq!( + pack_context_decode.as_ref().unwrap().dep_infos, + pack_context.dep_infos + ); + assert_eq!( + pack_context_decode.unwrap().crate_binary, + pack_context.crate_binary + ); + + fs::remove_file("test/crate-spec.cra").unwrap() }