-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add proc macro for running wiremock java in a docker image. Thi…
…s should help verifying stubr's feature parity with wiremock
- Loading branch information
Showing
93 changed files
with
433 additions
and
179 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# This is a systemd unit override file that enables the Docker Remote API on localhost. | ||
# To take effect, it should be placed at /etc/systemd/system/docker.service.d/override.conf. | ||
[Service] | ||
ExecStart= | ||
ExecStart=/usr/bin/dockerd -H fd:// -H tcp://127.0.0.1:2375 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
use proc_macro2::TokenStream; | ||
use quote::quote; | ||
|
||
pub(crate) fn iso_transform(args: syn::AttributeArgs, item: TokenStream) -> syn::Result<TokenStream> { | ||
let func = syn::parse2::<syn::ItemFn>(item)?; | ||
let ret = &func.sig.output; | ||
let name = &func.sig.ident; | ||
let body = &func.block; | ||
let attrs = &func.attrs; | ||
let vis = &func.vis; | ||
let asyncness = &func.sig.asyncness; | ||
let args: super::mock::Args = args.try_into()?; | ||
let wiremock_starter = super::wiremock::starter(&args); | ||
let stubr_starter = super::mock::starter(&func, &args); | ||
let stubr_name = proc_macro2::Ident::new(&format!("stubr_{}", name), name.span()); | ||
let wiremock_name = proc_macro2::Ident::new(&format!("wiremock_{}", name), name.span()); | ||
Ok(quote! { | ||
#(#attrs)* | ||
#vis #asyncness fn #stubr_name() #ret { | ||
#stubr_starter | ||
#body | ||
} | ||
#(#attrs)* | ||
#[cfg(wiremock_test)] | ||
#vis #asyncness fn #wiremock_name() #ret { | ||
use stubr::WiremockExt as _; | ||
#wiremock_starter | ||
#body | ||
} | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
use proc_macro2::TokenStream; | ||
use quote::quote; | ||
use syn::ItemFn; | ||
|
||
pub(crate) fn wiremock_transform(args: syn::AttributeArgs, item: TokenStream) -> syn::Result<TokenStream> { | ||
let func = syn::parse2::<ItemFn>(item)?; | ||
let ret = &func.sig.output; | ||
let name = &func.sig.ident; | ||
let body = &func.block; | ||
let attrs = &func.attrs; | ||
let vis = &func.vis; | ||
let asyncness = &func.sig.asyncness; | ||
let args: super::mock::Args = args.try_into()?; | ||
let starter = starter(&args); | ||
Ok(quote! { | ||
#(#attrs)* | ||
#vis #asyncness fn #name() #ret { | ||
#starter | ||
#body | ||
} | ||
}) | ||
} | ||
|
||
pub(crate) fn starter(args: &super::mock::Args) -> TokenStream { | ||
let path = args.path(); | ||
let _port = args.port(); | ||
quote! { | ||
let docker = testcontainers::clients::Cli::docker(); | ||
let stubr = stubr::WiremockImage::try_run(&docker, #path).unwrap(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
use crate::wiremock::ResponseTemplate; | ||
use crate::wiremock_rs::ResponseTemplate; | ||
|
||
pub struct SupersedeHyper; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
use crate::wiremock::Request; | ||
use crate::wiremock_rs::Request; | ||
use jsonwebtoken::Header; | ||
use serde_json::Value; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.