Remove a bit of noise
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone/pr Build is failing

This commit is contained in:
Alex 2022-04-26 14:35:07 +02:00
parent aedb1c1751
commit e9e76f6fc5
Signed by: lx
GPG key ID: 0E496D15096376BE
2 changed files with 19 additions and 10 deletions

View file

@ -91,16 +91,32 @@ impl<'a> RequestBuilder<'a> {
self
}
pub fn query_param<T, U>(&mut self, param: T, value: Option<U>) -> &mut Self
where T: ToString, U: ToString, {
self.query_params.insert(param.to_string(), value.as_ref().map(ToString::to_string));
self
}
pub fn signed_headers(&mut self, signed_headers: HashMap<String, String>) -> &mut Self {
self.signed_headers = signed_headers;
self
}
pub fn signed_header(&mut self, name: impl ToString, value: impl ToString) -> &mut Self {
self.signed_headers.insert(name.to_string(), value.to_string());
self
}
pub fn unsigned_headers(&mut self, unsigned_headers: HashMap<String, String>) -> &mut Self {
self.unsigned_headers = unsigned_headers;
self
}
pub fn unsigned_header(&mut self, name: impl ToString, value: impl ToString) -> &mut Self {
self.unsigned_headers.insert(name.to_string(), value.to_string());
self
}
pub fn body(&mut self, body: Vec<u8>) -> &mut Self {
self.body = body;
self

View file

@ -1,4 +1,3 @@
use std::collections::HashMap;
use crate::common;
use common::custom_requester::BodySignature;
@ -9,14 +8,11 @@ async fn test_simple() {
let ctx = common::context();
let bucket = ctx.create_bucket("test-k2v-simple");
let mut query_params = HashMap::new();
query_params.insert("sort_key".to_string(), Some("test1".to_string()));
let res = ctx.k2v.request
.builder(bucket.clone())
.method(Method::PUT)
.path("root".into())
.query_params(query_params.clone())
.query_param("sort_key", Some("test1"))
.body(b"Hello, world!".to_vec())
.body_signature(BodySignature::Classic)
.send()
@ -24,14 +20,11 @@ async fn test_simple() {
.unwrap();
assert_eq!(res.status(), 200);
let mut h = HashMap::new();
h.insert("accept".to_string(), "application/octet-stream".to_string());
let res2 = ctx.k2v.request
.builder(bucket.clone())
.path("root".into())
.query_params(query_params.clone())
.signed_headers(h)
.query_param("sort_key", Some("test1"))
.signed_header("accept", "application/octet-stream")
.body_signature(BodySignature::Classic)
.send()
.await