Skip to content

Commit

Permalink
Merge pull request #5 from wangkirin/main
Browse files Browse the repository at this point in the history
  • Loading branch information
genedna authored Jan 3, 2024
2 parents ab1a9ea + 4b0bec3 commit 294b2b5
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 12 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -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
6 changes: 0 additions & 6 deletions src/pack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
23 changes: 17 additions & 6 deletions src/unpack.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -42,9 +42,9 @@ pub fn unpack_context(file_path: &str, cas_path: Vec<String>) -> Result<PackageC

#[test]
fn test_unpack() {
use crate::pack::pack_context;
use super::utils::context::SIGTYPE;
let mut pack_context = pack_context("../crate-spec");
use crate::pack::pack_context;
let mut pack_context = pack_context(env::current_dir().unwrap().to_str().unwrap());
fn sign() -> PKCS {
let mut pkcs1 = PKCS::new();
pkcs1.load_from_file_writer(
Expand All @@ -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()
}

0 comments on commit 294b2b5

Please sign in to comment.