Skip to content

Commit

Permalink
Rename crates.
Browse files Browse the repository at this point in the history
  • Loading branch information
milesj committed Jan 24, 2024
1 parent 787dad2 commit 9c0cf57
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 7 deletions.
File renamed without changes.
2 changes: 1 addition & 1 deletion crates/dl/Cargo.toml → crates/download/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "moon_extension_dl"
name = "moon_extension_download"
version = "0.0.1"
edition = "2021"
license = "MIT"
Expand Down
4 changes: 2 additions & 2 deletions crates/dl/src/lib.rs → crates/download/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ extern "ExtismHost" {
}

#[derive(Args)]
pub struct DlExtensionArgs {
pub struct DownloadExtensionArgs {
#[arg(long, required = true)]
pub url: String,

Expand All @@ -25,7 +25,7 @@ pub struct DlExtensionArgs {

#[plugin_fn]
pub fn execute_extension(Json(input): Json<ExecuteExtensionInput>) -> FnResult<()> {
let args = parse_args::<DlExtensionArgs>(&input.args)?;
let args = parse_args::<DownloadExtensionArgs>(&input.args)?;

if !args.url.starts_with("http") {
return Err(plugin_err!("A valid URL is required for downloading."));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use moon_pdk_test_utils::{create_extension, ExecuteExtensionInput};
use starbase_sandbox::create_empty_sandbox;
use std::fs;

mod dl {
mod download {
use super::*;

#[test]
Expand Down
File renamed without changes.
6 changes: 5 additions & 1 deletion crates/dlu/Cargo.toml → crates/unpack/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "moon_extension_dlu"
name = "moon_extension_unpack"
version = "0.0.1"
edition = "2021"
license = "MIT"
Expand All @@ -16,3 +16,7 @@ starbase_archive = { version = "0.2.5", default-features = false, features = [
"tar-gz",
"zip",
] }

[dev-dependencies]
moon_pdk_test_utils = { workspace = true }
starbase_sandbox = { workspace = true }
4 changes: 2 additions & 2 deletions crates/dlu/src/lib.rs → crates/unpack/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ extern "ExtismHost" {
}

#[derive(Args)]
pub struct DluExtensionArgs {
pub struct UnpackExtensionArgs {
#[arg(long, short = 's', required = true)]
pub src: String,

Expand All @@ -27,7 +27,7 @@ pub struct DluExtensionArgs {

#[plugin_fn]
pub fn execute_extension(Json(input): Json<ExecuteExtensionInput>) -> FnResult<()> {
let args = parse_args::<DluExtensionArgs>(&input.args)?;
let args = parse_args::<UnpackExtensionArgs>(&input.args)?;

// Determine the correct input. If the input is a URL, attempt to download
// the file, otherwise use the file directly (if within our whitelist).
Expand Down
19 changes: 19 additions & 0 deletions crates/unpack/tests/unpack_test.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
use moon_pdk_test_utils::{create_extension, ExecuteExtensionInput};
use starbase_sandbox::create_empty_sandbox;
use std::fs;

mod unpack {
use super::*;

#[test]
#[should_panic(expected = "the following required arguments were not provided")]
fn errors_if_no_args() {
let sandbox = create_empty_sandbox();
let plugin = create_extension("test", sandbox.path());

plugin.execute_extension(ExecuteExtensionInput {
args: vec![],
context: plugin.create_context(sandbox.path()),
});
}
}

0 comments on commit 9c0cf57

Please sign in to comment.