From d9345e8fea90a0918e4e9f0d3cdd276fd786e61c Mon Sep 17 00:00:00 2001 From: Eguo Wang Date: Mon, 15 Jan 2024 10:22:07 +0800 Subject: [PATCH] refactor: using resource::{PlaybookSpec, ActorSpec} instead of actor::Actor and playbook::Playbook, bump version to 0.7.0 --- Cargo.toml | 4 +- src/actors.rs | 24 ++---- src/playbooks.rs | 28 ++----- tests/actors_test.rs | 14 +--- .../v1/api/actors/get-actor-success.http | 22 ++--- .../v1/api/actors/list-actors-success.http | 22 ++--- .../playbooks/create-playbook-created.http | 22 ++--- .../api/playbooks/get-playbook-success.http | 22 ++--- .../api/playbooks/list-playbooks-success.http | 22 ++--- .../playbooks/update-playbook-success.http | 22 ++--- tests/playbooks_test.rs | 82 +++++++++++-------- 11 files changed, 102 insertions(+), 182 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c812d26..33a44e7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "amp-client" description = "The Amphitheatre API client for Rust" -version = "0.6.4" +version = "0.7.0" edition = "2021" license = "Apache-2.0" homepage = "https://amphitheatre.app" @@ -11,7 +11,7 @@ readme = "README.md" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -amp-common = { git = "https://github.com/amphitheatre-app/common", tag = "v0.6.3" } +amp-common = { git = "https://github.com/amphitheatre-app/common", tag = "v0.7.0" } futures = "0.3" reqwest-eventsource = "0.5.0" serde = { version = "1.0", features = ["derive"] } diff --git a/src/actors.rs b/src/actors.rs index fcd439b..092ff0f 100644 --- a/src/actors.rs +++ b/src/actors.rs @@ -15,35 +15,21 @@ use std::collections::HashMap; use amp_common::http::{Client, Endpoint, HTTPError}; +use amp_common::resource::ActorSpec; use amp_common::sync::Synchronization; use reqwest_eventsource::EventSource; -use serde::{Deserialize, Serialize}; use serde_json::Value; -#[derive(Clone, Debug, Deserialize, Serialize)] -pub struct Actor { - /// The actor id - pub id: u64, - /// The title of the actor - pub title: String, - /// The description of the actor - pub description: String, - /// When the actor was created in Amphitheatre. - pub created_at: String, - /// When the actor was last updated in Amphitheatre. - pub updated_at: String, -} - struct ActorEndpoint; impl Endpoint for ActorEndpoint { - type Output = Actor; + type Output = ActorSpec; } struct ActorsEndpoint; impl Endpoint for ActorsEndpoint { - type Output = Vec; + type Output = Vec; } struct ValueEndpoint; @@ -71,7 +57,7 @@ impl Actors<'_> { &self, playbook_id: &str, options: Option>, - ) -> Result, HTTPError> { + ) -> Result, HTTPError> { let path = format!("/playbooks/{}/actors", playbook_id); let res = self.client.get::(&path, options)?; Ok(res.data.unwrap()) @@ -83,7 +69,7 @@ impl Actors<'_> { /// /// `pid`: The ID of the playbook /// `name`: The name of the actor - pub fn get(&self, pid: &str, name: &str) -> Result { + pub fn get(&self, pid: &str, name: &str) -> Result { let path = format!("/actors/{}/{}", pid, name); let res = self.client.get::(&path, None)?; Ok(res.data.unwrap()) diff --git a/src/playbooks.rs b/src/playbooks.rs index f8de8af..e5a304a 100644 --- a/src/playbooks.rs +++ b/src/playbooks.rs @@ -16,24 +16,10 @@ use std::collections::HashMap; use amp_common::{ http::{Client, Endpoint, HTTPError}, - resource::Preface, + resource::{PlaybookSpec, Preface}, }; use serde::{Deserialize, Serialize}; -#[derive(Clone, Debug, Deserialize, Serialize)] -pub struct Playbook { - /// The playbook ID in Amphitheatre. - pub id: String, - /// The title of the playbook. - pub title: String, - /// The description of the playbook. - pub description: String, - /// When the playbook was created in Amphitheatre. - pub created_at: String, - /// When the playbook was last updated in Amphitheatre. - pub updated_at: String, -} - #[derive(Debug, Deserialize, Serialize)] pub struct PlaybookPayload { /// The title of the playbook @@ -47,13 +33,13 @@ pub struct PlaybookPayload { struct PlaybookEndpoint; impl Endpoint for PlaybookEndpoint { - type Output = Playbook; + type Output = PlaybookSpec; } struct PlaybooksEndpoint; impl Endpoint for PlaybooksEndpoint { - type Output = Vec; + type Output = Vec; } /// The Playbooks Service handles the playbooks endpoint of the Amphitheatre API. @@ -70,7 +56,7 @@ impl Playbooks<'_> { /// /// `options`: The `RequestOptions` /// - Sort: `id`, `label`, `email` - pub fn list(&self, options: Option>) -> Result, HTTPError> { + pub fn list(&self, options: Option>) -> Result, HTTPError> { let res = self.client.get::("/playbooks", options)?; Ok(res.data.unwrap()) } @@ -81,7 +67,7 @@ impl Playbooks<'_> { /// /// `payload`: the `PlaybookPayload` with the information needed to create /// the playbook - pub fn create(&self, payload: PlaybookPayload) -> Result { + pub fn create(&self, payload: PlaybookPayload) -> Result { match serde_json::to_value(payload) { Ok(json) => { let res = self.client.post::("/playbooks", json)?; @@ -98,7 +84,7 @@ impl Playbooks<'_> { /// # Arguments /// /// `pid`: The ID of the playbook we want to retrieve - pub fn get(&self, pid: &str) -> Result { + pub fn get(&self, pid: &str) -> Result { let path = format!("/playbooks/{}", pid); let res = self.client.get::(&path, None)?; Ok(res.data.unwrap()) @@ -110,7 +96,7 @@ impl Playbooks<'_> { /// /// `pid`: The playbook id /// `payload`: The `PlaybookPayload` with the information needed to update - pub fn update(&self, pid: &str, payload: PlaybookPayload) -> Result { + pub fn update(&self, pid: &str, payload: PlaybookPayload) -> Result { let path = format!("/playbooks/{}", pid); match serde_json::to_value(payload) { diff --git a/tests/actors_test.rs b/tests/actors_test.rs index 793596b..fa1a43f 100644 --- a/tests/actors_test.rs +++ b/tests/actors_test.rs @@ -31,15 +31,11 @@ fn list_actors_test() { let actors = client.actors().list(pid, None).unwrap(); - assert_eq!(2, actors.len()); + assert_eq!(1, actors.len()); let actor = actors.first().unwrap(); - assert_eq!(1, actor.id); - assert_eq!("Default", actor.title); - assert_eq!("First", actor.description); - assert_eq!("2016-01-19T20:50:26Z", actor.created_at); - assert_eq!("2016-01-19T20:50:26Z", actor.updated_at); + assert_eq!("amp-example-go", actor.name); } #[test] @@ -51,11 +47,7 @@ fn get_actor_test() { let actor = client.actors().get(pid, name).unwrap(); - assert_eq!(1, actor.id); - assert_eq!("Default", actor.title); - assert_eq!("First", actor.description); - assert_eq!("2016-01-19T20:50:26Z", actor.created_at); - assert_eq!("2016-01-19T20:50:26Z", actor.updated_at); + assert_eq!("amp-example-go", actor.name); } #[tokio::test] diff --git a/tests/fixtures/v1/api/actors/get-actor-success.http b/tests/fixtures/v1/api/actors/get-actor-success.http index f235290..0a8d8ef 100644 --- a/tests/fixtures/v1/api/actors/get-actor-success.http +++ b/tests/fixtures/v1/api/actors/get-actor-success.http @@ -1,16 +1,6 @@ -HTTP/1.1 200 OK -Server: nginx -Date: Tue, 19 Jan 2016 20:50:26 GMT -Content-Type: application/json; charset=utf-8 -Connection: keep-alive -Status: 201 Created -x-ratelimit-limit: 4000 -x-ratelimit-remaining: 3997 -x-ratelimit-after: 1453239045 -ETag: W/"165299b0ea3e5c1c80f1ae622146626f" -Cache-Control: max-age=0, private, must-revalidate -X-Request-Id: 9f577b9e-5bc4-4a8f-adfb-09dbb1992b0e -X-Runtime: 0.061482 -Strict-Transport-Security: max-age=31536000 - -{"id":1,"title":"Default","description":"First","created_at":"2016-01-19T20:50:26Z","updated_at":"2016-01-19T20:50:26Z"} +HTTP/1.1 200 OK +content-type: application/json +content-length: 545 +date: Sun, 14 Jan 2024 10:22:26 GMT + +{"name":"amp-example-go","character":{"meta":{"name":"amp-example-go","version":"0.0.3","authors":["Eguo Wang "],"description":"A simple Golang example app","readme":"README.md","homepage":"https://github.com/amphitheatre-app/amp-example-go","repository":"https://github.com/amphitheatre-app/amp-example-go","license":"Apache-2.0","keywords":["example","golang","getting-started"],"categories":["example"]},"partners":{},"live":true,"once":true},"image":"index.docker.io/wangeguo/amp-example-go:live","live":true,"once":true} \ No newline at end of file diff --git a/tests/fixtures/v1/api/actors/list-actors-success.http b/tests/fixtures/v1/api/actors/list-actors-success.http index 1e1a04c..a3f870c 100644 --- a/tests/fixtures/v1/api/actors/list-actors-success.http +++ b/tests/fixtures/v1/api/actors/list-actors-success.http @@ -1,16 +1,6 @@ -HTTP/1.1 200 OK -Server: nginx -Date: Tue, 19 Jan 2016 20:50:26 GMT -Content-Type: application/json; charset=utf-8 -Connection: keep-alive -Status: 201 Created -x-ratelimit-limit: 4000 -x-ratelimit-remaining: 3997 -x-ratelimit-after: 1453239045 -ETag: W/"165299b0ea3e5c1c80f1ae622146626f" -Cache-Control: max-age=0, private, must-revalidate -X-Request-Id: 9f577b9e-5bc4-4a8f-adfb-09dbb1992b0e -X-Runtime: 0.061482 -Strict-Transport-Security: max-age=31536000 - -[{"id":1,"title":"Default","description":"First","created_at":"2016-01-19T20:50:26Z","updated_at":"2016-01-19T20:50:26Z"},{"id":2,"title":"Default","description":"First","created_at":"2016-01-19T20:50:26Z","updated_at":"2016-01-19T20:50:26Z"}] +HTTP/1.1 200 OK +content-type: application/json +content-length: 547 +date: Sun, 14 Jan 2024 10:25:24 GMT + +[{"name":"amp-example-go","character":{"meta":{"name":"amp-example-go","version":"0.0.3","authors":["Eguo Wang "],"description":"A simple Golang example app","readme":"README.md","homepage":"https://github.com/amphitheatre-app/amp-example-go","repository":"https://github.com/amphitheatre-app/amp-example-go","license":"Apache-2.0","keywords":["example","golang","getting-started"],"categories":["example"]},"partners":{},"live":true,"once":true},"image":"index.docker.io/wangeguo/amp-example-go:live","live":true,"once":true}] \ No newline at end of file diff --git a/tests/fixtures/v1/api/playbooks/create-playbook-created.http b/tests/fixtures/v1/api/playbooks/create-playbook-created.http index 5814083..82eddf3 100644 --- a/tests/fixtures/v1/api/playbooks/create-playbook-created.http +++ b/tests/fixtures/v1/api/playbooks/create-playbook-created.http @@ -1,16 +1,6 @@ -HTTP/1.1 201 Created -Server: nginx -Date: Tue, 19 Jan 2016 20:50:26 GMT -Content-Type: application/json; charset=utf-8 -Connection: keep-alive -Status: 201 Created -x-ratelimit-limit: 4000 -x-ratelimit-remaining: 3997 -x-ratelimit-after: 1453239045 -ETag: W/"165299b0ea3e5c1c80f1ae622146626f" -Cache-Control: max-age=0, private, must-revalidate -X-Request-Id: 9f577b9e-5bc4-4a8f-adfb-09dbb1992b0e -X-Runtime: 0.061482 -Strict-Transport-Security: max-age=31536000 - -{"id":"1","title":"Default","description":"First","created_at":"2016-01-19T20:50:26Z","updated_at":"2016-01-19T20:50:26Z"} +HTTP/1.1 200 OK +content-type: application/json +content-length: 1012 +date: Sun, 14 Jan 2024 10:20:36 GMT + +{"title":"Untitled","description":"","namespace":"amp-a82abba3-df2f-4608-b1a5-9e058ff80468","preface":{"name":"amp-example-go","manifest":{"meta":{"name":"amp-example-go","version":"0.0.3","authors":["Eguo Wang "],"description":"A simple Golang example app","readme":"README.md","homepage":"https://github.com/amphitheatre-app/amp-example-go","repository":"https://github.com/amphitheatre-app/amp-example-go","license":"Apache-2.0","keywords":["example","golang","getting-started"],"categories":["example"]},"partners":{},"live":true,"once":true}},"characters":[{"meta":{"name":"amp-example-go","version":"0.0.3","authors":["Eguo Wang "],"description":"A simple Golang example app","readme":"README.md","homepage":"https://github.com/amphitheatre-app/amp-example-go","repository":"https://github.com/amphitheatre-app/amp-example-go","license":"Apache-2.0","keywords":["example","golang","getting-started"],"categories":["example"]},"partners":{},"live":true,"once":true}]} \ No newline at end of file diff --git a/tests/fixtures/v1/api/playbooks/get-playbook-success.http b/tests/fixtures/v1/api/playbooks/get-playbook-success.http index af38bf8..82eddf3 100644 --- a/tests/fixtures/v1/api/playbooks/get-playbook-success.http +++ b/tests/fixtures/v1/api/playbooks/get-playbook-success.http @@ -1,16 +1,6 @@ -HTTP/1.1 200 OK -Server: nginx -Date: Tue, 19 Jan 2016 20:50:26 GMT -Content-Type: application/json; charset=utf-8 -Connection: keep-alive -Status: 201 Created -x-ratelimit-limit: 4000 -x-ratelimit-remaining: 3997 -x-ratelimit-after: 1453239045 -ETag: W/"165299b0ea3e5c1c80f1ae622146626f" -Cache-Control: max-age=0, private, must-revalidate -X-Request-Id: 9f577b9e-5bc4-4a8f-adfb-09dbb1992b0e -X-Runtime: 0.061482 -Strict-Transport-Security: max-age=31536000 - -{"id":"1","title":"Default","description":"First","created_at":"2016-01-19T20:50:26Z","updated_at":"2016-01-19T20:50:26Z"} +HTTP/1.1 200 OK +content-type: application/json +content-length: 1012 +date: Sun, 14 Jan 2024 10:20:36 GMT + +{"title":"Untitled","description":"","namespace":"amp-a82abba3-df2f-4608-b1a5-9e058ff80468","preface":{"name":"amp-example-go","manifest":{"meta":{"name":"amp-example-go","version":"0.0.3","authors":["Eguo Wang "],"description":"A simple Golang example app","readme":"README.md","homepage":"https://github.com/amphitheatre-app/amp-example-go","repository":"https://github.com/amphitheatre-app/amp-example-go","license":"Apache-2.0","keywords":["example","golang","getting-started"],"categories":["example"]},"partners":{},"live":true,"once":true}},"characters":[{"meta":{"name":"amp-example-go","version":"0.0.3","authors":["Eguo Wang "],"description":"A simple Golang example app","readme":"README.md","homepage":"https://github.com/amphitheatre-app/amp-example-go","repository":"https://github.com/amphitheatre-app/amp-example-go","license":"Apache-2.0","keywords":["example","golang","getting-started"],"categories":["example"]},"partners":{},"live":true,"once":true}]} \ No newline at end of file diff --git a/tests/fixtures/v1/api/playbooks/list-playbooks-success.http b/tests/fixtures/v1/api/playbooks/list-playbooks-success.http index 241b861..4f0100f 100644 --- a/tests/fixtures/v1/api/playbooks/list-playbooks-success.http +++ b/tests/fixtures/v1/api/playbooks/list-playbooks-success.http @@ -1,16 +1,6 @@ -HTTP/1.1 200 OK -Server: nginx -Date: Tue, 19 Jan 2016 20:50:26 GMT -Content-Type: application/json; charset=utf-8 -Connection: keep-alive -Status: 201 Created -x-ratelimit-limit: 4000 -x-ratelimit-remaining: 3997 -x-ratelimit-after: 1453239045 -ETag: W/"165299b0ea3e5c1c80f1ae622146626f" -Cache-Control: max-age=0, private, must-revalidate -X-Request-Id: 9f577b9e-5bc4-4a8f-adfb-09dbb1992b0e -X-Runtime: 0.061482 -Strict-Transport-Security: max-age=31536000 - -[{"id":"1","title":"Default","description":"First","created_at":"2016-01-19T20:50:26Z","updated_at":"2016-01-19T20:50:26Z"},{"id":"2","title":"Default","description":"First","created_at":"2016-01-19T20:50:26Z","updated_at":"2016-01-19T20:50:26Z"}] +HTTP/1.1 200 OK +content-type: application/json +content-length: 1014 +date: Sun, 14 Jan 2024 10:19:55 GMT + +[{"title":"Untitled","description":"","namespace":"amp-a82abba3-df2f-4608-b1a5-9e058ff80468","preface":{"name":"amp-example-go","manifest":{"meta":{"name":"amp-example-go","version":"0.0.3","authors":["Eguo Wang "],"description":"A simple Golang example app","readme":"README.md","homepage":"https://github.com/amphitheatre-app/amp-example-go","repository":"https://github.com/amphitheatre-app/amp-example-go","license":"Apache-2.0","keywords":["example","golang","getting-started"],"categories":["example"]},"partners":{},"live":true,"once":true}},"characters":[{"meta":{"name":"amp-example-go","version":"0.0.3","authors":["Eguo Wang "],"description":"A simple Golang example app","readme":"README.md","homepage":"https://github.com/amphitheatre-app/amp-example-go","repository":"https://github.com/amphitheatre-app/amp-example-go","license":"Apache-2.0","keywords":["example","golang","getting-started"],"categories":["example"]},"partners":{},"live":true,"once":true}]}] \ No newline at end of file diff --git a/tests/fixtures/v1/api/playbooks/update-playbook-success.http b/tests/fixtures/v1/api/playbooks/update-playbook-success.http index af38bf8..82eddf3 100644 --- a/tests/fixtures/v1/api/playbooks/update-playbook-success.http +++ b/tests/fixtures/v1/api/playbooks/update-playbook-success.http @@ -1,16 +1,6 @@ -HTTP/1.1 200 OK -Server: nginx -Date: Tue, 19 Jan 2016 20:50:26 GMT -Content-Type: application/json; charset=utf-8 -Connection: keep-alive -Status: 201 Created -x-ratelimit-limit: 4000 -x-ratelimit-remaining: 3997 -x-ratelimit-after: 1453239045 -ETag: W/"165299b0ea3e5c1c80f1ae622146626f" -Cache-Control: max-age=0, private, must-revalidate -X-Request-Id: 9f577b9e-5bc4-4a8f-adfb-09dbb1992b0e -X-Runtime: 0.061482 -Strict-Transport-Security: max-age=31536000 - -{"id":"1","title":"Default","description":"First","created_at":"2016-01-19T20:50:26Z","updated_at":"2016-01-19T20:50:26Z"} +HTTP/1.1 200 OK +content-type: application/json +content-length: 1012 +date: Sun, 14 Jan 2024 10:20:36 GMT + +{"title":"Untitled","description":"","namespace":"amp-a82abba3-df2f-4608-b1a5-9e058ff80468","preface":{"name":"amp-example-go","manifest":{"meta":{"name":"amp-example-go","version":"0.0.3","authors":["Eguo Wang "],"description":"A simple Golang example app","readme":"README.md","homepage":"https://github.com/amphitheatre-app/amp-example-go","repository":"https://github.com/amphitheatre-app/amp-example-go","license":"Apache-2.0","keywords":["example","golang","getting-started"],"categories":["example"]},"partners":{},"live":true,"once":true}},"characters":[{"meta":{"name":"amp-example-go","version":"0.0.3","authors":["Eguo Wang "],"description":"A simple Golang example app","readme":"README.md","homepage":"https://github.com/amphitheatre-app/amp-example-go","repository":"https://github.com/amphitheatre-app/amp-example-go","license":"Apache-2.0","keywords":["example","golang","getting-started"],"categories":["example"]},"partners":{},"live":true,"once":true}]} \ No newline at end of file diff --git a/tests/playbooks_test.rs b/tests/playbooks_test.rs index 1c076c5..1e15055 100644 --- a/tests/playbooks_test.rs +++ b/tests/playbooks_test.rs @@ -24,15 +24,15 @@ fn list_playbooks_test() { let playbooks = client.playbooks().list(None).unwrap(); - assert_eq!(2, playbooks.len()); + assert_eq!(1, playbooks.len()); let playbook = playbooks.first().unwrap(); - assert_eq!("1", playbook.id); - assert_eq!("Default", playbook.title); - assert_eq!("First", playbook.description); - assert_eq!("2016-01-19T20:50:26Z", playbook.created_at); - assert_eq!("2016-01-19T20:50:26Z", playbook.updated_at); + assert_eq!("amp-a82abba3-df2f-4608-b1a5-9e058ff80468", playbook.id()); + assert_eq!("Untitled", playbook.title); + assert_eq!(Some("".into()), playbook.description); + // assert_eq!("2016-01-19T20:50:26Z", playbook.created_at); + // assert_eq!("2016-01-19T20:50:26Z", playbook.updated_at); } #[test] @@ -41,57 +41,73 @@ fn create_playbook_test() { let client = setup.0; let payload = PlaybookPayload { - title: String::from("Default"), - description: String::from("First"), + title: String::from("Untitled"), + description: String::from(""), preface: Preface::default(), }; let playbook = client.playbooks().create(payload).unwrap(); - assert_eq!("1", playbook.id); - assert_eq!("Default", playbook.title); - assert_eq!("First", playbook.description); + assert_eq!("amp-a82abba3-df2f-4608-b1a5-9e058ff80468", playbook.id()); + assert_eq!("Untitled", playbook.title); + assert_eq!(Some("".into()), playbook.description); + // assert_eq!("2016-01-19T20:50:26Z", playbook.created_at); + // assert_eq!("2016-01-19T20:50:26Z", playbook.updated_at); } #[test] fn get_playbook_test() { - let setup = setup_mock_for("/playbooks/1", "playbooks/get-playbook-success", "GET"); + let setup = setup_mock_for( + "/playbooks/amp-a82abba3-df2f-4608-b1a5-9e058ff80468", + "playbooks/get-playbook-success", + "GET", + ); let client = setup.0; - let playbook_id = "1"; + let playbook_id = "amp-a82abba3-df2f-4608-b1a5-9e058ff80468"; let playbook = client.playbooks().get(playbook_id).unwrap(); - assert_eq!("1", playbook.id); - assert_eq!("Default", playbook.title); - assert_eq!("First", playbook.description); - assert_eq!("2016-01-19T20:50:26Z", playbook.created_at); - assert_eq!("2016-01-19T20:50:26Z", playbook.updated_at); + assert_eq!("amp-a82abba3-df2f-4608-b1a5-9e058ff80468", playbook.id()); + assert_eq!("Untitled", playbook.title); + assert_eq!(Some("".into()), playbook.description); + // assert_eq!("2016-01-19T20:50:26Z", playbook.created_at); + // assert_eq!("2016-01-19T20:50:26Z", playbook.updated_at); } #[test] fn update_playbook_test() { - let setup = setup_mock_for("/playbooks/1", "playbooks/update-playbook-success", "PATCH"); + let setup = setup_mock_for( + "/playbooks/amp-a82abba3-df2f-4608-b1a5-9e058ff80468", + "playbooks/update-playbook-success", + "PATCH", + ); let client = setup.0; - let playbook_id = "1"; + let playbook_id = "amp-a82abba3-df2f-4608-b1a5-9e058ff80468"; let payload = PlaybookPayload { - title: String::from("Default"), - description: String::from("First"), + title: String::from("Untitled"), + description: String::from(""), preface: Preface::default(), }; let playbook = client.playbooks().update(playbook_id, payload).unwrap(); - assert_eq!("1", playbook.id); - assert_eq!("Default", playbook.title); - assert_eq!("First", playbook.description); + assert_eq!("amp-a82abba3-df2f-4608-b1a5-9e058ff80468", playbook.id()); + assert_eq!("Untitled", playbook.title); + assert_eq!(Some("".into()), playbook.description); + // assert_eq!("2016-01-19T20:50:26Z", playbook.created_at); + // assert_eq!("2016-01-19T20:50:26Z", playbook.updated_at); } #[test] fn delete_playbook_test() { - let setup = setup_mock_for("/playbooks/1", "playbooks/delete-playbook-success", "DELETE"); + let setup = setup_mock_for( + "/playbooks/amp-a82abba3-df2f-4608-b1a5-9e058ff80468", + "playbooks/delete-playbook-success", + "DELETE", + ); let client = setup.0; - let playbook_id = "1"; + let playbook_id = "amp-a82abba3-df2f-4608-b1a5-9e058ff80468"; let response = client.playbooks().delete(playbook_id); @@ -102,12 +118,12 @@ fn delete_playbook_test() { #[test] fn get_playbook_events() { let setup = setup_mock_for( - "/playbooks/1/events", + "/playbooks/amp-a82abba3-df2f-4608-b1a5-9e058ff80468/events", "playbooks/get-playbook-events-success", "GET", ); let client = setup.0; - let playbook_id = "1"; + let playbook_id = "amp-a82abba3-df2f-4608-b1a5-9e058ff80468"; let response = client.playbooks().events(playbook_id); @@ -117,12 +133,12 @@ fn get_playbook_events() { #[test] fn start_playbook_test() { let setup = setup_mock_for( - "/playbooks/1/actions/start", + "/playbooks/amp-a82abba3-df2f-4608-b1a5-9e058ff80468/actions/start", "playbooks/start-playbook-success", "POST", ); let client = setup.0; - let playbook_id = "1"; + let playbook_id = "amp-a82abba3-df2f-4608-b1a5-9e058ff80468"; let response = client.playbooks().start(playbook_id); @@ -133,12 +149,12 @@ fn start_playbook_test() { #[test] fn stop_playbook_test() { let setup = setup_mock_for( - "/playbooks/1/actions/stop", + "/playbooks/amp-a82abba3-df2f-4608-b1a5-9e058ff80468/actions/stop", "playbooks/stop-playbook-success", "POST", ); let client = setup.0; - let playbook_id = "1"; + let playbook_id = "amp-a82abba3-df2f-4608-b1a5-9e058ff80468"; let response = client.playbooks().stop(playbook_id);