mirror of
https://github.com/SeriousBug/gandi-live-dns-rust
synced 2024-11-16 20:29:01 -06:00
wip
This commit is contained in:
parent
80d8c8885b
commit
9e9940dc5d
|
@ -22,3 +22,6 @@ anyhow = "1.0"
|
||||||
governor = "0.4"
|
governor = "0.4"
|
||||||
# TODO: Relies on a yet-unreleased interface. Switch to an actual crate release once available
|
# TODO: Relies on a yet-unreleased interface. Switch to an actual crate release once available
|
||||||
die-exit = { git = "https://github.com/Xavientois/die.git", rev = "31d3801f4e21654b0b28430987b1e21fc7728676" }
|
die-exit = { git = "https://github.com/Xavientois/die.git", rev = "31d3801f4e21654b0b28430987b1e21fc7728676" }
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
httpmock = "0.6"
|
||||||
|
|
29
src/main.rs
29
src/main.rs
|
@ -123,3 +123,32 @@ async fn main() -> anyhow::Result<()> {
|
||||||
|
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use httpmock::MockServer;
|
||||||
|
use serde_json::json;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn create_repo_success_test() {
|
||||||
|
// Arrange
|
||||||
|
let server = MockServer::start();
|
||||||
|
let mock = server.mock(|when, then| {
|
||||||
|
when.method("POST")
|
||||||
|
.path("/user/repos")
|
||||||
|
.header("Authorization", "token TOKEN")
|
||||||
|
.header("Content-Type", "application/json");
|
||||||
|
then.status(201)
|
||||||
|
.json_body(json!({ "html_url": "http://example.com" }));
|
||||||
|
});
|
||||||
|
let client = GithubClient::new("TOKEN", &server.base_url());
|
||||||
|
|
||||||
|
// Act
|
||||||
|
let result = client.create_repo("myRepo");
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
mock.assert();
|
||||||
|
assert_eq!(result.is_ok(), true);
|
||||||
|
assert_eq!(result.unwrap(), "http://example.com");
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue