1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
use derive_builder::Builder;
use crate::api::common::NameOrId;
use crate::api::endpoint_prelude::*;
#[derive(Debug, Builder)]
pub struct EraseJob<'a> {
#[builder(setter(into))]
project: NameOrId<'a>,
job: u64,
}
impl<'a> EraseJob<'a> {
pub fn builder() -> EraseJobBuilder<'a> {
EraseJobBuilder::default()
}
}
impl<'a> Endpoint for EraseJob<'a> {
fn method(&self) -> Method {
Method::POST
}
fn endpoint(&self) -> Cow<'static, str> {
format!("projects/{}/jobs/{}/erase", self.project, self.job).into()
}
}
#[cfg(test)]
mod tests {
use http::Method;
use crate::api::projects::jobs::EraseJob;
use crate::api::{self, Query};
use crate::test::client::{ExpectedUrl, SingleTestClient};
#[test]
fn project_and_job_are_needed() {
let err = EraseJob::builder().build().unwrap_err();
assert_eq!(err, "`project` must be initialized");
}
#[test]
fn project_is_needed() {
let err = EraseJob::builder().job(1).build().unwrap_err();
assert_eq!(err, "`project` must be initialized");
}
#[test]
fn job_is_needed() {
let err = EraseJob::builder().project(1).build().unwrap_err();
assert_eq!(err, "`job` must be initialized");
}
#[test]
fn project_and_job_are_sufficient() {
EraseJob::builder().project(1).job(1).build().unwrap();
}
#[test]
fn endpoint() {
let endpoint = ExpectedUrl::builder()
.method(Method::POST)
.endpoint("projects/simple%2Fproject/jobs/1/erase")
.build()
.unwrap();
let client = SingleTestClient::new_raw(endpoint, "");
let endpoint = EraseJob::builder()
.project("simple/project")
.job(1)
.build()
.unwrap();
api::ignore(endpoint).query(&client).unwrap();
}
}