Skip to main content

azure_devops/constants/
mod.rs

1pub mod content_type;
2pub mod http_headers;
3pub mod messages;
4pub mod paths;
5pub mod query_params;
6
7pub const DEFAULT_API_VERSION: &str = "7.1";
8pub const AZURE_DEVOPS_URL: &str = "https://dev.azure.com";
9pub const NULL_JSON: &str = "null";
10pub const USER_AGENT: &str = "azure-devops-rust-api";
11
12/// JSON key for extracting error messages from Azure DevOps API error responses.
13pub const JSON_MESSAGE_KEY: &str = "message";
14
15pub use content_type::ct;
16pub use http_headers::hdr;
17pub use messages::msg;
18pub use paths::ApiPath;
19pub use query_params::query;
20
21#[cfg(test)]
22mod tests {
23    use super::*;
24
25    #[test]
26    fn project_paths() {
27        assert_eq!(ApiPath::projects(), "_apis/projects");
28        assert_eq!(ApiPath::project("abc"), "_apis/projects/abc");
29    }
30    #[test]
31    fn work_item_paths() {
32        assert_eq!(ApiPath::work_item(42), "_apis/wit/workitems/42");
33        assert_eq!(ApiPath::work_item_create("P", "Bug"), "P/_apis/wit/workitems/$Bug");
34        assert_eq!(ApiPath::wiql("P"), "P/_apis/wit/wiql");
35    }
36    #[test]
37    fn git_paths() {
38        assert_eq!(ApiPath::repository("r"), "_apis/git/repositories/r");
39        assert_eq!(ApiPath::prs("r"), "_apis/git/repositories/r/pullrequests");
40    }
41    #[test]
42    fn build_paths() {
43        assert_eq!(ApiPath::builds("P"), "P/_apis/build/builds");
44        assert_eq!(
45            ApiPath::build_badge("https://dev.azure.com/org/", 10),
46            "https://dev.azure.com/org/_apis/public/build/definitions/10/badge"
47        );
48    }
49    #[test]
50    fn pipeline_paths() {
51        assert_eq!(ApiPath::pipelines("P"), "P/_apis/pipelines");
52    }
53}