|
16 | 16 | */
|
17 | 17 |
|
18 | 18 | use dropshot::endpoint;
|
| 19 | +use dropshot::test_util::object_delete; |
19 | 20 | use dropshot::test_util::read_json;
|
20 | 21 | use dropshot::test_util::read_string;
|
21 | 22 | use dropshot::ApiDescription;
|
22 | 23 | use dropshot::HttpError;
|
| 24 | +use dropshot::HttpResponseDeleted; |
23 | 25 | use dropshot::HttpResponseOk;
|
24 | 26 | use dropshot::Path;
|
25 | 27 | use dropshot::Query;
|
@@ -52,6 +54,7 @@ fn demo_api() -> ApiDescription<usize> {
|
52 | 54 | api.register(demo_handler_path_param_uuid).unwrap();
|
53 | 55 | api.register(demo_handler_path_param_u32).unwrap();
|
54 | 56 | api.register(demo_handler_untyped_body).unwrap();
|
| 57 | + api.register(demo_handler_delete).unwrap(); |
55 | 58 |
|
56 | 59 | /*
|
57 | 60 | * We don't need to exhaustively test these cases, as they're tested by unit
|
@@ -602,6 +605,20 @@ async fn test_untyped_body() {
|
602 | 605 | testctx.teardown().await;
|
603 | 606 | }
|
604 | 607 |
|
| 608 | +/* |
| 609 | + * Test delete request |
| 610 | + */ |
| 611 | +#[tokio::test] |
| 612 | +async fn test_delete_request() { |
| 613 | + let api = demo_api(); |
| 614 | + let testctx = common::test_setup("test_delete_request", api); |
| 615 | + let client = &testctx.client_testctx; |
| 616 | + |
| 617 | + object_delete(&client, "/testing/delete").await; |
| 618 | + |
| 619 | + testctx.teardown().await; |
| 620 | +} |
| 621 | + |
605 | 622 | /*
|
606 | 623 | * Demo handler functions
|
607 | 624 | */
|
@@ -765,6 +782,16 @@ async fn demo_handler_path_param_impossible(
|
765 | 782 | http_echo(&path_params.into_inner())
|
766 | 783 | }
|
767 | 784 |
|
| 785 | +#[endpoint { |
| 786 | + method = DELETE, |
| 787 | + path = "/testing/delete", |
| 788 | +}] |
| 789 | +async fn demo_handler_delete( |
| 790 | + _rqctx: RequestCtx, |
| 791 | +) -> Result<HttpResponseDeleted, HttpError> { |
| 792 | + Ok(HttpResponseDeleted()) |
| 793 | +} |
| 794 | + |
768 | 795 | fn http_echo<T: Serialize>(t: &T) -> Result<Response<Body>, HttpError> {
|
769 | 796 | Ok(Response::builder()
|
770 | 797 | .header(http::header::CONTENT_TYPE, CONTENT_TYPE_JSON)
|
|
0 commit comments