-
-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
//! Interfaces for accessing and managing the backlog | ||
|
||
use {EmptyResponse, Jira, Result}; | ||
|
||
#[derive(Debug, Serialize)] | ||
struct BacklogIssues { | ||
issues: Vec<String>, | ||
} | ||
|
||
#[derive(Debug)] | ||
pub struct Backlog { | ||
jira: Jira, | ||
} | ||
|
||
impl Backlog { | ||
pub fn new(jira: &Jira) -> Self { | ||
Backlog { jira: jira.clone() } | ||
} | ||
|
||
// See https://docs.atlassian.com/jira-software/REST/7.0.4/#agile/1.0/backlog | ||
pub fn put(&self, issues: Vec<String>) -> Result<EmptyResponse> { | ||
let data = BacklogIssues { issues }; | ||
|
||
self.jira.post("agile", "/backlog/issue", data) | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod test { | ||
extern crate serde_json; | ||
|
||
use super::*; | ||
|
||
#[test] | ||
fn serialise_backlog_issue() { | ||
let backlog = BacklogIssues { | ||
issues: vec!["PR-1".to_owned(), "10001".to_owned(), "PR-3".to_owned()], | ||
}; | ||
|
||
let result: String = serde_json::to_string(&backlog).unwrap(); | ||
let expected = r#"{"issues":["PR-1","10001","PR-3"]}"#; | ||
|
||
assert_eq!(result, expected); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
extern crate goji; | ||
extern crate serde_json; | ||
|
||
use goji::*; | ||
|
||
#[test] | ||
fn deserialise_empty_response() { | ||
let empty_response_str = "null"; | ||
let empty_response: EmptyResponse = serde_json::from_str(empty_response_str).unwrap(); | ||
|
||
assert_eq!(format!("{:#?}", empty_response), "EmptyResponse"); | ||
} |