Skip to content

Commit

Permalink
upgrade to 0.90 and use body-collect helper (#69)
Browse files Browse the repository at this point in the history
* showcase body-collect

Signed-off-by: clux <sszynrae@gmail.com>

* even simpler

Signed-off-by: clux <sszynrae@gmail.com>

* fix everywhere

Signed-off-by: clux <sszynrae@gmail.com>

* use main

Signed-off-by: clux <sszynrae@gmail.com>

* use official

Signed-off-by: clux <sszynrae@gmail.com>

---------

Signed-off-by: clux <sszynrae@gmail.com>
  • Loading branch information
clux committed Apr 3, 2024
1 parent 1125df0 commit 3d58a74
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 26 deletions.
36 changes: 17 additions & 19 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,12 @@ anyhow = "1.0.75"
[dev-dependencies]
assert-json-diff = "2.0.2"
http = "1"
http-body-util = "0.1.1"
hyper = "1"
tower-test = "0.4.0"

[dependencies.kube]
features = ["runtime", "client", "derive" ]
version = "0.89.0"
version = "0.90.0"

# testing new releases - ignore
#git = "https://github.com/kube-rs/kube.git"
Expand Down
9 changes: 4 additions & 5 deletions src/fixtures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
use crate::{Context, Document, DocumentSpec, DocumentStatus, Metrics, Result, DOCUMENT_FINALIZER};
use assert_json_diff::assert_json_include;
use http::{Request, Response};
use http_body_util::BodyExt;
use kube::{client::Body, Client, Resource, ResourceExt};
use prometheus::Registry;
use std::sync::Arc;
Expand Down Expand Up @@ -129,7 +128,7 @@ impl ApiServerVerifier {
{ "op": "test", "path": "/metadata/finalizers", "value": null },
{ "op": "add", "path": "/metadata/finalizers", "value": vec![DOCUMENT_FINALIZER] }
]);
let req_body = request.into_body().collect().await.unwrap().to_bytes();
let req_body = request.into_body().collect_bytes().await.unwrap();
let runtime_patch: serde_json::Value =
serde_json::from_slice(&req_body).expect("valid document from runtime");
assert_json_include!(actual: runtime_patch, expected: expected_patch);
Expand All @@ -154,7 +153,7 @@ impl ApiServerVerifier {
{ "op": "test", "path": "/metadata/finalizers/0", "value": DOCUMENT_FINALIZER },
{ "op": "remove", "path": "/metadata/finalizers/0", "path": "/metadata/finalizers/0" }
]);
let req_body = request.into_body().collect().await.unwrap().to_bytes();
let req_body = request.into_body().collect_bytes().await.unwrap();
let runtime_patch: serde_json::Value =
serde_json::from_slice(&req_body).expect("valid document from runtime");
assert_json_include!(actual: runtime_patch, expected: expected_patch);
Expand All @@ -172,7 +171,7 @@ impl ApiServerVerifier {
format!("/apis/events.k8s.io/v1/namespaces/default/events?")
);
// verify the event reason matches the expected
let req_body = request.into_body().collect().await.unwrap().to_bytes();
let req_body = request.into_body().collect_bytes().await.unwrap();
let postdata: serde_json::Value =
serde_json::from_slice(&req_body).expect("valid event from runtime");
dbg!("postdata for event: {}", postdata.clone());
Expand All @@ -195,7 +194,7 @@ impl ApiServerVerifier {
doc.name_any()
)
);
let req_body = request.into_body().collect().await.unwrap().to_bytes();
let req_body = request.into_body().collect_bytes().await.unwrap();
let json: serde_json::Value = serde_json::from_slice(&req_body).expect("patch_status object is json");
let status_json = json.get("status").expect("status object").clone();
let status: DocumentStatus = serde_json::from_value(status_json).expect("valid status");
Expand Down

0 comments on commit 3d58a74

Please sign in to comment.