|
1 | | -// Copyright 2023 Oxide Computer Company |
| 1 | +// Copyright 2024 Oxide Computer Company |
2 | 2 |
|
3 | 3 | //! Generation of mocking extensions for `httpmock` |
4 | 4 |
|
@@ -94,36 +94,36 @@ impl Generator { |
94 | 94 | let code = quote! { |
95 | 95 | pub mod operations { |
96 | 96 |
|
97 | | - //! [`When`](httpmock::When) and [`Then`](httpmock::Then) |
| 97 | + //! [`When`](::httpmock::When) and [`Then`](::httpmock::Then) |
98 | 98 | //! wrappers for each operation. Each can be converted to |
99 | 99 | //! its inner type with a call to `into_inner()`. This can |
100 | 100 | //! be used to explicitly deviate from permitted values. |
101 | 101 |
|
102 | 102 | use #crate_path::*; |
103 | 103 |
|
104 | 104 | #( |
105 | | - pub struct #when(httpmock::When); |
| 105 | + pub struct #when(::httpmock::When); |
106 | 106 | #when_impl |
107 | 107 |
|
108 | | - pub struct #then(httpmock::Then); |
| 108 | + pub struct #then(::httpmock::Then); |
109 | 109 | #then_impl |
110 | 110 | )* |
111 | 111 | } |
112 | 112 |
|
113 | | - /// An extension trait for [`MockServer`](httpmock::MockServer) that |
| 113 | + /// An extension trait for [`MockServer`](::httpmock::MockServer) that |
114 | 114 | /// adds a method for each operation. These are the equivalent of |
115 | | - /// type-checked [`mock()`](httpmock::MockServer::mock) calls. |
| 115 | + /// type-checked [`mock()`](::httpmock::MockServer::mock) calls. |
116 | 116 | pub trait MockServerExt { |
117 | 117 | #( |
118 | | - fn #op<F>(&self, config_fn: F) -> httpmock::Mock |
| 118 | + fn #op<F>(&self, config_fn: F) -> ::httpmock::Mock |
119 | 119 | where |
120 | 120 | F: FnOnce(operations::#when, operations::#then); |
121 | 121 | )* |
122 | 122 | } |
123 | 123 |
|
124 | | - impl MockServerExt for httpmock::MockServer { |
| 124 | + impl MockServerExt for ::httpmock::MockServer { |
125 | 125 | #( |
126 | | - fn #op<F>(&self, config_fn: F) -> httpmock::Mock |
| 126 | + fn #op<F>(&self, config_fn: F) -> ::httpmock::Mock |
127 | 127 | where |
128 | 128 | F: FnOnce(operations::#when, operations::#then) |
129 | 129 | { |
@@ -152,14 +152,14 @@ impl Generator { |
152 | 152 | let then = format_ident!("{}", then_name).to_token_stream(); |
153 | 153 |
|
154 | 154 | let http_method = match &method.method { |
155 | | - HttpMethod::Get => quote! { httpmock::Method::GET }, |
156 | | - HttpMethod::Put => quote! { httpmock::Method::PUT }, |
157 | | - HttpMethod::Post => quote! { httpmock::Method::POST }, |
158 | | - HttpMethod::Delete => quote! { httpmock::Method::DELETE }, |
159 | | - HttpMethod::Options => quote! { httpmock::Method::OPTIONS }, |
160 | | - HttpMethod::Head => quote! { httpmock::Method::HEAD }, |
161 | | - HttpMethod::Patch => quote! { httpmock::Method::PATCH }, |
162 | | - HttpMethod::Trace => quote! { httpmock::Method::TRACE }, |
| 155 | + HttpMethod::Get => quote! { ::httpmock::Method::GET }, |
| 156 | + HttpMethod::Put => quote! { ::httpmock::Method::PUT }, |
| 157 | + HttpMethod::Post => quote! { ::httpmock::Method::POST }, |
| 158 | + HttpMethod::Delete => quote! { ::httpmock::Method::DELETE }, |
| 159 | + HttpMethod::Options => quote! { ::httpmock::Method::OPTIONS }, |
| 160 | + HttpMethod::Head => quote! { ::httpmock::Method::HEAD }, |
| 161 | + HttpMethod::Patch => quote! { ::httpmock::Method::PATCH }, |
| 162 | + HttpMethod::Trace => quote! { ::httpmock::Method::TRACE }, |
163 | 163 | }; |
164 | 164 |
|
165 | 165 | let path_re = method.path.as_wildcard(); |
@@ -284,13 +284,13 @@ impl Generator { |
284 | 284 |
|
285 | 285 | let when_impl = quote! { |
286 | 286 | impl #when { |
287 | | - pub fn new(inner: httpmock::When) -> Self { |
| 287 | + pub fn new(inner: ::httpmock::When) -> Self { |
288 | 288 | Self(inner |
289 | 289 | .method(#http_method) |
290 | 290 | .path_matches(regex::Regex::new(#path_re).unwrap())) |
291 | 291 | } |
292 | 292 |
|
293 | | - pub fn into_inner(self) -> httpmock::When { |
| 293 | + pub fn into_inner(self) -> ::httpmock::When { |
294 | 294 | self.0 |
295 | 295 | } |
296 | 296 |
|
@@ -404,11 +404,11 @@ impl Generator { |
404 | 404 |
|
405 | 405 | let then_impl = quote! { |
406 | 406 | impl #then { |
407 | | - pub fn new(inner: httpmock::Then) -> Self { |
| 407 | + pub fn new(inner: ::httpmock::Then) -> Self { |
408 | 408 | Self(inner) |
409 | 409 | } |
410 | 410 |
|
411 | | - pub fn into_inner(self) -> httpmock::Then { |
| 411 | + pub fn into_inner(self) -> ::httpmock::Then { |
412 | 412 | self.0 |
413 | 413 | } |
414 | 414 |
|
|
0 commit comments