From 75b4b28050eacdfe1900051319471037659bc65f Mon Sep 17 00:00:00 2001 From: Jeremy Andrews Date: Sun, 1 May 2022 08:54:07 +0200 Subject: [PATCH 1/2] update to goose 0.16.0 --- Cargo.toml | 4 +- examples/umami/admin.rs | 4 +- examples/umami/common.rs | 35 +++++++------ examples/umami/english.rs | 20 ++++---- examples/umami/main.rs | 101 ++++++++++++++++++++++++-------------- examples/umami/spanish.rs | 18 +++---- src/drupal.rs | 22 ++++----- src/lib.rs | 30 +++++------ 8 files changed, 129 insertions(+), 105 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 09211de..fa66d83 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "goose-eggs" -version = "0.3.1" +version = "0.4.0" authors = ["Jeremy Andrews "] edition = "2018" description = "Helpful in writing Goose load tests." @@ -12,7 +12,7 @@ keywords = ["loadtesting", "performance", "web"] license = "Apache-2.0" [dependencies] -goose = "0.15" +goose = "0.16" log = "0.4" rand = "0.8" regex = "1.5" diff --git a/examples/umami/admin.rs b/examples/umami/admin.rs index 6bc081b..c38f049 100644 --- a/examples/umami/admin.rs +++ b/examples/umami/admin.rs @@ -6,7 +6,7 @@ use rand::seq::SliceRandom; use std::env; /// Log into the website. -pub async fn log_in(user: &mut GooseUser) -> GooseTaskResult { +pub async fn log_in(user: &mut GooseUser) -> TransactionResult { // Use ADMIN_USERNAME= to set custom admin username. let admin_username = match env::var("ADMIN_USERNAME") { Ok(username) => username, @@ -29,7 +29,7 @@ pub async fn log_in(user: &mut GooseUser) -> GooseTaskResult { } /// Load and edit a random article. -pub async fn edit_article(user: &mut GooseUser) -> GooseTaskResult { +pub async fn edit_article(user: &mut GooseUser) -> TransactionResult { // First, load a random article. let nodes = common::get_nodes(&common::ContentType::Article); let article = nodes.choose(&mut rand::thread_rng()); diff --git a/examples/umami/common.rs b/examples/umami/common.rs index 4f64d1a..403cd5d 100644 --- a/examples/umami/common.rs +++ b/examples/umami/common.rs @@ -34,67 +34,59 @@ pub fn get_nodes(content_type: &ContentType) -> Vec { ContentType::Article => { vec![ Node { - nid: 10, + nid: 11, url_en: "en/articles/give-it-a-go-and-grow-your-own-herbs", url_es: "es/articles/prueba-y-cultiva-tus-propias-hierbas", title_en: "Give it a go and grow your own herbs", title_es: "Prueba y cultiva tus propias hierbas", }, Node { - nid: 11, + nid: 12, url_en: "en/articles/dairy-free-and-delicious-milk-chocolate", url_es: "es/articles/delicioso-chocolate-sin-lactosa", title_en: "Dairy-free and delicious milk chocolate", title_es: "Delicioso chocolate sin lactosa", }, Node { - nid: 12, + nid: 13, url_en: "en/articles/the-real-deal-for-supermarket-savvy-shopping", url_es: "es/articles/el-verdadeo-negocio-para-comprar-en-el-supermercado", title_en: "The real deal for supermarket savvy shopping", title_es: "El verdadero negocio para comprar en el supermercado", }, Node { - nid: 13, + nid: 14, url_en: "en/articles/the-umami-guide-to-our-favourite-mushrooms", url_es: "es/articles/guia-umami-de-nuestras-setas-preferidas", title_en: "The Umami guide to our favorite mushrooms", title_es: "Guía Umami de nuestras setas preferidas", }, Node { - nid: 14, + nid: 15, url_en: "en/articles/lets-hear-it-for-carrots", url_es: "es/articles/un-aplauso-para-las-zanahorias", title_en: "Let's hear it for carrots", title_es: "Un aplauso para las zanahorias", }, Node { - nid: 15, + nid: 16, url_en: "en/articles/baking-mishaps-our-troubleshooting-tips", - url_es: - "es/articles/percances-al-hornear-nuestros-consejos-para-solucionar-problemas", + url_es: "es/articles/percances-al-hornear-nuestros-consejos-para-solucionar-problemas", title_en: "Baking mishaps - our troubleshooting tips", title_es: "Percances al hornear - nuestros consejos para solucionar los problemas", }, Node { - nid: 16, + nid: 17, url_en: "en/articles/skip-the-spirits-with-delicious-mocktails", url_es: "es/articles/salta-los-espiritus-con-deliciosos-cocteles-sin-alcohol", title_en: "Skip the spirits with delicious mocktails", title_es: "Salta los espíritus con deliciosos cócteles sin alcohol", }, - Node { - nid: 17, - url_en: "en/articles/give-your-oatmeal-the-ultimate-makeover", - url_es: "es/articles/dale-a-tu-avena-el-cambio-de-imagen-definitivo", - title_en: "Give your oatmeal the ultimate makeover", - title_es: "Dale a tu avena el cambio de imagen definitivo", - }, ] } ContentType::BasicPage => { vec![Node { - nid: 18, + nid: 19, url_en: "en/about-umami", url_es: "es/acerca-de-umami", title_en: "About Umami", @@ -166,6 +158,13 @@ pub fn get_nodes(content_type: &ContentType) -> Vec { title_en: "Fiery chili sauce", title_es: "Salsa de chile ardiente", }, + Node { + nid: 10, + url_en: "en/recipes/borscht-with-pork-ribs", + url_es: "es/recipes/borscht-con-costillas-de-cerdo", + title_en: "Borscht with pork ribs", + title_es: "Borscht con costillas de cerdo", + }, ] } } @@ -414,7 +413,7 @@ pub fn random_words(count: usize, english: bool) -> Vec { /// Anonymously load the contact form and POST feedback. The english boolean flag indicates /// whether to load the English form or the Spanish form. -pub async fn anonymous_contact_form(user: &mut GooseUser, english: bool) -> GooseTaskResult { +pub async fn anonymous_contact_form(user: &mut GooseUser, english: bool) -> TransactionResult { let contact_form_url = if english { "en/contact" } else { "es/contact" }; let goose = user.get(contact_form_url).await?; let contact_page = goose_eggs::validate_and_load_static_assets( diff --git a/examples/umami/english.rs b/examples/umami/english.rs index af9d290..90738de 100644 --- a/examples/umami/english.rs +++ b/examples/umami/english.rs @@ -5,7 +5,7 @@ use crate::common; use rand::seq::SliceRandom; /// Load the front page in English and all static assets found on the page. -pub async fn front_page_en(user: &mut GooseUser) -> GooseTaskResult { +pub async fn front_page_en(user: &mut GooseUser) -> TransactionResult { let goose = user.get("").await?; goose_eggs::validate_and_load_static_assets( user, @@ -18,7 +18,7 @@ pub async fn front_page_en(user: &mut GooseUser) -> GooseTaskResult { } /// Load recipe listing in English and all static assets found on the page. -pub async fn recipe_listing_en(user: &mut GooseUser) -> GooseTaskResult { +pub async fn recipe_listing_en(user: &mut GooseUser) -> TransactionResult { let goose = user.get("en/recipes/").await?; goose_eggs::validate_and_load_static_assets( user, @@ -31,7 +31,7 @@ pub async fn recipe_listing_en(user: &mut GooseUser) -> GooseTaskResult { } /// Load a random recipe in English and all static assets found on the page. -pub async fn recipe_en(user: &mut GooseUser) -> GooseTaskResult { +pub async fn recipe_en(user: &mut GooseUser) -> TransactionResult { let nodes = common::get_nodes(&common::ContentType::Recipe); let recipe = nodes.choose(&mut rand::thread_rng()); let goose = user.get(recipe.unwrap().url_en).await?; @@ -48,7 +48,7 @@ pub async fn recipe_en(user: &mut GooseUser) -> GooseTaskResult { } /// Load article listing in English and all static assets found on the page. -pub async fn article_listing_en(user: &mut GooseUser) -> GooseTaskResult { +pub async fn article_listing_en(user: &mut GooseUser) -> TransactionResult { let goose = user.get("en/articles/").await?; goose_eggs::validate_and_load_static_assets( user, @@ -61,7 +61,7 @@ pub async fn article_listing_en(user: &mut GooseUser) -> GooseTaskResult { } /// Load a random article in English and all static assets found on the page. -pub async fn article_en(user: &mut GooseUser) -> GooseTaskResult { +pub async fn article_en(user: &mut GooseUser) -> TransactionResult { let nodes = common::get_nodes(&common::ContentType::Article); let article = nodes.choose(&mut rand::thread_rng()); let goose = user.get(article.unwrap().url_en).await?; @@ -78,7 +78,7 @@ pub async fn article_en(user: &mut GooseUser) -> GooseTaskResult { } /// Load a random basic page in English and all static assets found on the page. -pub async fn basic_page_en(user: &mut GooseUser) -> GooseTaskResult { +pub async fn basic_page_en(user: &mut GooseUser) -> TransactionResult { let nodes = common::get_nodes(&common::ContentType::BasicPage); let page = nodes.choose(&mut rand::thread_rng()); let goose = user.get(page.unwrap().url_en).await?; @@ -95,7 +95,7 @@ pub async fn basic_page_en(user: &mut GooseUser) -> GooseTaskResult { } /// Load a random node by nid in English and all static assets found on the page. -pub async fn page_by_nid(user: &mut GooseUser) -> GooseTaskResult { +pub async fn page_by_nid(user: &mut GooseUser) -> TransactionResult { // Randomly select a content type. let content_types = vec![ common::ContentType::Article, @@ -123,14 +123,14 @@ pub async fn page_by_nid(user: &mut GooseUser) -> GooseTaskResult { } /// Anonymously load the contact form in English and POST feedback. -pub async fn anonymous_contact_form_en(user: &mut GooseUser) -> GooseTaskResult { +pub async fn anonymous_contact_form_en(user: &mut GooseUser) -> TransactionResult { common::anonymous_contact_form(user, true).await?; Ok(()) } // Pick a random word from the title of a random node and perform a search in English. -pub async fn search_en(user: &mut GooseUser) -> GooseTaskResult { +pub async fn search_en(user: &mut GooseUser) -> TransactionResult { // Build a random three-word phrase taken from english words on the Umami website. let search_words = common::random_words(3, true); let search_phrase = search_words.join(" "); @@ -153,7 +153,7 @@ pub async fn search_en(user: &mut GooseUser) -> GooseTaskResult { } /// Load category listing by a random term in English and all static assets found on the page. -pub async fn term_listing_en(user: &mut GooseUser) -> GooseTaskResult { +pub async fn term_listing_en(user: &mut GooseUser) -> TransactionResult { let terms = common::get_terms(); let term = terms.choose(&mut rand::thread_rng()); let goose = user.get(term.unwrap().url_en).await?; diff --git a/examples/umami/main.rs b/examples/umami/main.rs index 4282694..0321708 100644 --- a/examples/umami/main.rs +++ b/examples/umami/main.rs @@ -17,76 +17,101 @@ use crate::spanish::*; #[tokio::main] async fn main() -> Result<(), GooseError> { let _goose_metrics = GooseAttack::initialize()? - .register_taskset( - taskset!("Anonymous English user") + .register_scenario( + scenario!("Anonymous English user") .set_weight(40)? .set_wait_time(Duration::from_secs(0), Duration::from_secs(3))? - .register_task(task!(front_page_en).set_name("anon /").set_weight(2)?) - .register_task(task!(basic_page_en).set_name("anon /en/basicpage")) - .register_task(task!(article_listing_en).set_name("anon /en/articles/")) - .register_task( - task!(article_en) + .register_transaction( + transaction!(front_page_en) + .set_name("anon /") + .set_weight(2)?, + ) + .register_transaction(transaction!(basic_page_en).set_name("anon /en/basicpage")) + .register_transaction( + transaction!(article_listing_en).set_name("anon /en/articles/"), + ) + .register_transaction( + transaction!(article_en) .set_name("anon /en/articles/%") .set_weight(2)?, ) - .register_task(task!(recipe_listing_en).set_name("anon /en/recipes/")) - .register_task( - task!(recipe_en) + .register_transaction(transaction!(recipe_listing_en).set_name("anon /en/recipes/")) + .register_transaction( + transaction!(recipe_en) .set_name("anon /en/recipes/%") .set_weight(4)?, ) - .register_task(task!(page_by_nid).set_name("anon /node/%nid")) - .register_task( - task!(term_listing_en) + .register_transaction(transaction!(page_by_nid).set_name("anon /node/%nid")) + .register_transaction( + transaction!(term_listing_en) .set_name("anon /en term") .set_weight(2)?, ) - .register_task(task!(search_en).set_name("anon /en/search")) - .register_task(task!(anonymous_contact_form_en).set_name("anon /en/contact")), + .register_transaction(transaction!(search_en).set_name("anon /en/search")) + .register_transaction( + transaction!(anonymous_contact_form_en).set_name("anon /en/contact"), + ), ) - .register_taskset( - taskset!("Anonymous Spanish user") + .register_scenario( + scenario!("Anonymous Spanish user") .set_weight(9)? .set_wait_time(Duration::from_secs(0), Duration::from_secs(3))? - .register_task(task!(front_page_es).set_name("anon /es/").set_weight(2)?) - .register_task(task!(basic_page_es).set_name("anon /es/basicpage")) - .register_task(task!(article_listing_es).set_name("anon /es/articles/")) - .register_task( - task!(article_es) + .register_transaction( + transaction!(front_page_es) + .set_name("anon /es/") + .set_weight(2)?, + ) + .register_transaction(transaction!(basic_page_es).set_name("anon /es/basicpage")) + .register_transaction( + transaction!(article_listing_es).set_name("anon /es/articles/"), + ) + .register_transaction( + transaction!(article_es) .set_name("anon /es/articles/%") .set_weight(2)?, ) - .register_task(task!(recipe_listing_es).set_name("anon /es/recipes/")) - .register_task( - task!(recipe_es) + .register_transaction(transaction!(recipe_listing_es).set_name("anon /es/recipes/")) + .register_transaction( + transaction!(recipe_es) .set_name("anon /es/recipes/%") .set_weight(4)?, ) - .register_task( - task!(term_listing_es) + .register_transaction( + transaction!(term_listing_es) .set_name("anon /es term") .set_weight(2)?, ) - .register_task(task!(search_es).set_name("anon /es/search")) - .register_task(task!(anonymous_contact_form_es).set_name("anon /es/contact")), + .register_transaction(transaction!(search_es).set_name("anon /es/search")) + .register_transaction( + transaction!(anonymous_contact_form_es).set_name("anon /es/contact"), + ), ) - .register_taskset( - taskset!("Admin user") + .register_scenario( + scenario!("Admin user") .set_weight(1)? .set_wait_time(Duration::from_secs(0), Duration::from_secs(3))? - .register_task(task!(log_in).set_on_start().set_name("auth /en/user/login")) - .register_task(task!(front_page_en).set_name("auth /").set_weight(2)?) - .register_task(task!(article_listing_en).set_name("auth /en/articles/")) - .register_task( - task!(edit_article) + .register_transaction( + transaction!(log_in) + .set_on_start() + .set_name("auth /en/user/login"), + ) + .register_transaction( + transaction!(front_page_en) + .set_name("auth /") + .set_weight(2)?, + ) + .register_transaction( + transaction!(article_listing_en).set_name("auth /en/articles/"), + ) + .register_transaction( + transaction!(edit_article) .set_name("auth /en/node/%/edit") .set_weight(2)?, ), ) .set_default(GooseDefault::Host, "https://drupal-9.ddev.site/")? .execute() - .await? - .print(); + .await?; Ok(()) } diff --git a/examples/umami/spanish.rs b/examples/umami/spanish.rs index a43e9bc..9e3e609 100644 --- a/examples/umami/spanish.rs +++ b/examples/umami/spanish.rs @@ -5,7 +5,7 @@ use crate::common; use rand::seq::SliceRandom; /// Load the front page in Spanish and all static assets found on the page. -pub async fn front_page_es(user: &mut GooseUser) -> GooseTaskResult { +pub async fn front_page_es(user: &mut GooseUser) -> TransactionResult { let goose = user.get("es").await?; goose_eggs::validate_and_load_static_assets( user, @@ -18,7 +18,7 @@ pub async fn front_page_es(user: &mut GooseUser) -> GooseTaskResult { } /// Load article listing in Spanish and all static assets found on the page. -pub async fn recipe_listing_es(user: &mut GooseUser) -> GooseTaskResult { +pub async fn recipe_listing_es(user: &mut GooseUser) -> TransactionResult { let goose = user.get("es/recipes/").await?; goose_eggs::validate_and_load_static_assets( user, @@ -31,7 +31,7 @@ pub async fn recipe_listing_es(user: &mut GooseUser) -> GooseTaskResult { } /// Load a random recipe in Spanish and all static assets found on the page. -pub async fn recipe_es(user: &mut GooseUser) -> GooseTaskResult { +pub async fn recipe_es(user: &mut GooseUser) -> TransactionResult { let nodes = common::get_nodes(&common::ContentType::Recipe); let recipe = nodes.choose(&mut rand::thread_rng()); let goose = user.get(recipe.unwrap().url_es).await?; @@ -48,7 +48,7 @@ pub async fn recipe_es(user: &mut GooseUser) -> GooseTaskResult { } /// Load article listing in Spanish and all static assets found on the page. -pub async fn article_listing_es(user: &mut GooseUser) -> GooseTaskResult { +pub async fn article_listing_es(user: &mut GooseUser) -> TransactionResult { let goose = user.get("es/articles/").await?; goose_eggs::validate_and_load_static_assets( user, @@ -61,7 +61,7 @@ pub async fn article_listing_es(user: &mut GooseUser) -> GooseTaskResult { } /// Load a random article in Spanish and all static assets found on the page. -pub async fn article_es(user: &mut GooseUser) -> GooseTaskResult { +pub async fn article_es(user: &mut GooseUser) -> TransactionResult { let nodes = common::get_nodes(&common::ContentType::Article); let article = nodes.choose(&mut rand::thread_rng()); let goose = user.get(article.unwrap().url_es).await?; @@ -78,7 +78,7 @@ pub async fn article_es(user: &mut GooseUser) -> GooseTaskResult { } /// Load a basic page in Spanish and all static assets found on the page. -pub async fn basic_page_es(user: &mut GooseUser) -> GooseTaskResult { +pub async fn basic_page_es(user: &mut GooseUser) -> TransactionResult { let nodes = common::get_nodes(&common::ContentType::BasicPage); let page = nodes.choose(&mut rand::thread_rng()); let goose = user.get(page.unwrap().url_es).await?; @@ -95,14 +95,14 @@ pub async fn basic_page_es(user: &mut GooseUser) -> GooseTaskResult { } /// Anonymously load the contact form in Spanish and POST feedback. -pub async fn anonymous_contact_form_es(user: &mut GooseUser) -> GooseTaskResult { +pub async fn anonymous_contact_form_es(user: &mut GooseUser) -> TransactionResult { common::anonymous_contact_form(user, false).await?; Ok(()) } // Pick a random word from the title of a random node and perform a search in Spanish. -pub async fn search_es(user: &mut GooseUser) -> GooseTaskResult { +pub async fn search_es(user: &mut GooseUser) -> TransactionResult { // Build a random three-word phrase taken from Spanish words on the Umami website. let search_words = common::random_words(3, false); let search_phrase = search_words.join(" "); @@ -125,7 +125,7 @@ pub async fn search_es(user: &mut GooseUser) -> GooseTaskResult { } /// Load category listing by a random term in Spanish and all static assets found on the page. -pub async fn term_listing_es(user: &mut GooseUser) -> GooseTaskResult { +pub async fn term_listing_es(user: &mut GooseUser) -> TransactionResult { let terms = common::get_terms(); let term = terms.choose(&mut rand::thread_rng()); let goose = user.get(term.unwrap().url_es).await?; diff --git a/src/drupal.rs b/src/drupal.rs index f03f7fd..5219f14 100644 --- a/src/drupal.rs +++ b/src/drupal.rs @@ -545,7 +545,7 @@ impl<'a> LoginBuilder<'a> { /// Log into a Drupal website. /// -/// The reference to a GooseUser object is from a Goose task function. The optional +/// The reference to a GooseUser object is from a transaction function. The optional /// pointer to a [`Login`] object can be created to override the username, password, /// login url, or expected page title after log in. /// @@ -562,9 +562,9 @@ impl<'a> LoginBuilder<'a> { /// use goose::prelude::*; /// use goose_eggs::drupal::{log_in, Login}; /// -/// task!(login).set_on_start(); +/// transaction!(login).set_on_start(); /// -/// async fn login(user: &mut GooseUser) -> GooseTaskResult { +/// async fn login(user: &mut GooseUser) -> TransactionResult { /// // By default log in with `foo`:`bar`. /// let login = Login::builder() /// .username("foo") @@ -576,7 +576,7 @@ impl<'a> LoginBuilder<'a> { /// } /// /// ``` -pub async fn log_in(user: &mut GooseUser, login: &Login<'_>) -> Result { +pub async fn log_in(user: &mut GooseUser, login: &Login<'_>) -> Result { // Use the `GOOSE_USER` environment variable if it's set, otherwise use the specified // (or default) login username. let username = env::var("GOOSE_USER").unwrap_or_else(|_| login.username.to_string()); @@ -727,9 +727,9 @@ impl<'a> SearchParams<'a> { /// use goose::prelude::*; /// use goose_eggs::drupal; /// -/// task!(search); +/// transaction!(search); /// -/// async fn search(user: &mut GooseUser) -> GooseTaskResult { +/// async fn search(user: &mut GooseUser) -> TransactionResult { /// // Define the search parameters. /// let search_params = drupal::SearchParams::builder() /// // Search for the keys "search terms". @@ -750,9 +750,9 @@ impl<'a> SearchParams<'a> { /// use goose::prelude::*; /// use goose_eggs::{Validate, drupal}; /// -/// task!(search); +/// transaction!(search); /// -/// async fn search(user: &mut GooseUser) -> GooseTaskResult { +/// async fn search(user: &mut GooseUser) -> TransactionResult { /// // Define the search parameters. /// // Verify that the search form page has a title that includes "Custom Search". /// let validate_search_page = Validate::builder() @@ -995,9 +995,9 @@ impl<'a> SearchParamsBuilder<'a> { /// use goose::prelude::*; /// use goose_eggs::drupal; /// -/// task!(search); +/// transaction!(search); /// -/// async fn search(user: &mut GooseUser) -> GooseTaskResult { +/// async fn search(user: &mut GooseUser) -> TransactionResult { /// // Use the default search form to search for "foo", validating that the /// // search page has a title of Search. /// let validate_search_page = &goose_eggs::Validate::builder() @@ -1016,7 +1016,7 @@ impl<'a> SearchParamsBuilder<'a> { pub async fn search<'a>( user: &mut GooseUser, params: &'a SearchParams<'a>, -) -> Result { +) -> Result { // Load the search page. let goose = user.get(params.url).await?; diff --git a/src/lib.rs b/src/lib.rs index 965c4ec..286fc6b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -62,9 +62,9 @@ impl<'a> Validate<'a> { /// use goose::prelude::*; /// use goose_eggs::{validate_and_load_static_assets, Validate}; /// -/// task!(load_and_validate_page); +/// transaction!(load_and_validate_page); /// -/// async fn load_and_validate_page(user: &mut GooseUser) -> GooseTaskResult { +/// async fn load_and_validate_page(user: &mut GooseUser) -> TransactionResult { /// // Make a GET request. /// let mut goose = user.get("example/path").await?; /// @@ -426,9 +426,9 @@ pub fn get_title(html: &str) -> Option { /// use goose::prelude::*; /// use goose_eggs::valid_title; /// -/// task!(validate_title).set_on_start(); +/// transaction!(validate_title).set_on_start(); /// -/// async fn validate_title(user: &mut GooseUser) -> GooseTaskResult { +/// async fn validate_title(user: &mut GooseUser) -> TransactionResult { /// let mut goose = user.get("/").await?; /// /// match goose.response { @@ -498,9 +498,9 @@ pub fn valid_title(html: &str, title: &str) -> bool { /// use goose::prelude::*; /// use goose_eggs::valid_text; /// -/// task!(validate_text).set_on_start(); +/// transaction!(validate_text).set_on_start(); /// -/// async fn validate_text(user: &mut GooseUser) -> GooseTaskResult { +/// async fn validate_text(user: &mut GooseUser) -> TransactionResult { /// let mut goose = user.get("/").await?; /// /// match goose.response { @@ -558,9 +558,9 @@ pub fn valid_text(html: &str, text: &str) -> bool { /// use goose::prelude::*; /// use goose_eggs::header_is_set; /// -/// task!(validate_header).set_on_start(); +/// transaction!(validate_header).set_on_start(); /// -/// async fn validate_header(user: &mut GooseUser) -> GooseTaskResult { +/// async fn validate_header(user: &mut GooseUser) -> TransactionResult { /// let mut goose = user.get("/").await?; /// /// match goose.response { @@ -608,9 +608,9 @@ pub fn header_is_set(headers: &HeaderMap, header: &str) -> bool { /// use goose::prelude::*; /// use goose_eggs::valid_header_value; /// -/// task!(validate_header_value).set_on_start(); +/// transaction!(validate_header_value).set_on_start(); /// -/// async fn validate_header_value(user: &mut GooseUser) -> GooseTaskResult { +/// async fn validate_header_value(user: &mut GooseUser) -> TransactionResult { /// let mut goose = user.get("/").await?; /// /// match goose.response { @@ -683,9 +683,9 @@ pub fn valid_header_value<'a>(headers: &HeaderMap, header: (&'a str, &'a str)) - /// use goose::prelude::*; /// use goose_eggs::load_static_elements; /// -/// task!(load_page_and_static_elements).set_on_start(); +/// transaction!(load_page_and_static_elements).set_on_start(); /// -/// async fn load_page_and_static_elements(user: &mut GooseUser) -> GooseTaskResult { +/// async fn load_page_and_static_elements(user: &mut GooseUser) -> TransactionResult { /// let mut goose = user.get("/").await?; /// /// match goose.response { @@ -760,9 +760,9 @@ pub async fn load_static_elements(user: &mut GooseUser, html: &str) { /// use goose::prelude::*; /// use goose_eggs::{validate_and_load_static_assets, Validate}; /// -/// task!(load_page).set_on_start(); +/// transaction!(load_page).set_on_start(); /// -/// async fn load_page(user: &mut GooseUser) -> GooseTaskResult { +/// async fn load_page(user: &mut GooseUser) -> TransactionResult { /// let mut goose = user.get("/").await?; /// validate_and_load_static_assets( /// user, @@ -781,7 +781,7 @@ pub async fn validate_and_load_static_assets<'a>( user: &mut GooseUser, mut goose: GooseResponse, validate: &'a Validate<'a>, -) -> Result { +) -> Result { let empty = "".to_string(); match goose.response { Ok(response) => { From 6d2b3923281ceade02a23df41cc05975a497f762 Mon Sep 17 00:00:00 2001 From: Jeremy Andrews Date: Sun, 1 May 2022 09:02:56 +0200 Subject: [PATCH 2/2] clippy fixes --- CHANGELOG.md | 3 +++ src/drupal.rs | 4 ++-- src/lib.rs | 4 ++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e8b0c30..26552ab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## 0.4.0 May 1, 2022 + - update goose to [0.16](https://github.com/tag1consulting/goose/releases/tag/0.16.0) + ## 0.3.1 November 2, 2021 - update goose to [0.15](https://github.com/tag1consulting/goose/releases/tag/0.15.0) diff --git a/src/drupal.rs b/src/drupal.rs index 5219f14..e4dbe76 100644 --- a/src/drupal.rs +++ b/src/drupal.rs @@ -44,7 +44,7 @@ pub fn get_form(html: &str, name: &str) -> String { )) .unwrap(); // Strip carriage returns to simplify regex. - let line = html.replace("\n", ""); + let line = html.replace('\n', ""); // Return the entire form, a subset of the received html. match re.captures(&line) { Some(capture) => capture[2].to_string(), @@ -153,7 +153,7 @@ pub fn get_bigpipe_form(html: &str, name: &str) -> String { ) .unwrap(); // Strip carriage returns to simplify regex. - let line = html.replace("\n", ""); + let line = html.replace('\n', ""); // Return the entire form, a subset of the received html. match re.captures(&line) { Some(capture) => capture[1].to_string(), diff --git a/src/lib.rs b/src/lib.rs index 286fc6b..cc2339b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -354,7 +354,7 @@ impl<'a> ValidateBuilder<'a> { pub fn get_html_header(html: &str) -> Option { let re = Regex::new(r#""#).unwrap(); // Strip carriage returns to simplify regex. - let line = html.replace("\n", ""); + let line = html.replace('\n', ""); // Return the entire html header, a subset of the received html. re.captures(&line).map(|value| value[0].to_string()) } @@ -394,7 +394,7 @@ pub fn get_html_header(html: &str) -> Option { pub fn get_title(html: &str) -> Option { let re = Regex::new(r#"(.*?)"#).unwrap(); // Strip carriage returns to simplify regex. - let line = html.replace("\n", ""); + let line = html.replace('\n', ""); // Return the entire title, a subset of the received html. re.captures(&line).map(|value| value[1].to_string()) }