moonlit-pdk 0.2.0

SDK for writing Moonlit release-pipeline plugins as WebAssembly components.
Documentation
//! Exercises the `moonlit_plugin!`-generated `Guest` impl natively (host target).
//! The generated code uses `__MoonlitUnavailableHost` off-wasm, so we assert on
//! init metadata, the middleware list, and unknown-middleware dispatch — paths
//! that do not depend on host calls.

use moonlit_pdk::bindings::Guest;
use moonlit_pdk::prelude::*;

#[derive(Default)]
struct Alpha;
impl Middleware for Alpha {
  const NAME: &'static str = "alpha";
  const DESCRIPTION: &'static str = "first";
  type Input = NoInput;
  type Output = NoOutput;
  fn execute(&self, _ctx: &Context, _input: Self::Input) -> MiddlewareResult<Self::Output> {
    MiddlewareResult::ok(NoOutput {})
  }
}

moonlit_plugin! {
    name: "sample",
    middlewares: [Alpha],
}

#[test]
fn init_reports_name_and_version() {
  let meta = <MoonlitComponent as Guest>::init("{}".to_string()).unwrap();
  assert_eq!(meta.name, "sample");
  assert_eq!(meta.version, env!("CARGO_PKG_VERSION"));
}

#[test]
fn lists_declared_middlewares() {
  let mws = <MoonlitComponent as Guest>::list_middlewares();
  assert_eq!(mws.len(), 1);
  assert_eq!(mws[0].name, "alpha");
  assert_eq!(mws[0].description, "first");
}

#[test]
fn describe_omits_icon_when_unset() {
  // This plugin declares no `icon:`, so the ABI-0.2.0 icon field is None.
  assert!(<MoonlitComponent as Guest>::describe().icon.is_none());
}