From 001b75343f26d39c3c2991c1e72042913252a483 Mon Sep 17 00:00:00 2001 From: Adam Curtis Date: Mon, 17 Jul 2023 16:00:56 -0400 Subject: [PATCH] template pagination test --- tests/test_environments.rs | 18 ++++++++---------- tests/test_projects.rs | 10 ++++------ tests/test_templates.rs | 19 +++++++++++++++++++ 3 files changed, 31 insertions(+), 16 deletions(-) diff --git a/tests/test_environments.rs b/tests/test_environments.rs index fd838748d..c811866e9 100644 --- a/tests/test_environments.rs +++ b/tests/test_environments.rs @@ -1,8 +1,6 @@ use cloudtruth_test_harness::prelude::*; use std::str; -const TEST_PAGE_SIZE: usize = 5; - #[test] #[use_harness] fn test_environments_basic() { @@ -197,17 +195,17 @@ fn test_environments_parents() { #[test] #[use_harness] fn test_environments_pagination() { - let page_size = TEST_PAGE_SIZE; + const PAGE_SIZE: usize = 5; // we store the project names so they're not instantly dropped and deleted - let _envs: Vec> = (0..=page_size) + let _envs: Vec> = (0..=PAGE_SIZE) .map(|i| Environment::with_prefix(format!("env-page-{}", i)).create()) .collect(); cloudtruth!("env ls") .rest_debug() - .page_size(page_size) + .page_size(PAGE_SIZE) .assert() .success() - .paginated(page_size); + .paginated(PAGE_SIZE); } #[test] @@ -328,17 +326,17 @@ fn test_environments_tagging() { fn test_environments_tagging_pagination() { let env = Environment::with_prefix("env-pag-tag").create(); - let page_size = TEST_PAGE_SIZE; - for n in 0..=page_size { + const PAGE_SIZE: usize = 5; + for n in 0..=PAGE_SIZE { let tag = Name::with_prefix(format!("tag-{n}")); cloudtruth!("env tag set {env} {tag}").assert().success(); } cloudtruth!("env tag ls {env}") .rest_debug() - .page_size(page_size) + .page_size(PAGE_SIZE) .assert() .success() - .paginated(page_size); + .paginated(PAGE_SIZE); } #[test] diff --git a/tests/test_projects.rs b/tests/test_projects.rs index ddbadb62e..65e8b7174 100644 --- a/tests/test_projects.rs +++ b/tests/test_projects.rs @@ -1,7 +1,5 @@ use cloudtruth_test_harness::prelude::*; -const TEST_PAGE_SIZE: usize = 5; - #[test] #[use_harness] fn test_projects_basic() { @@ -129,17 +127,17 @@ fn test_projects_parents() { #[test] #[use_harness] fn test_projects_pagination() { - let page_size = TEST_PAGE_SIZE; + const PAGE_SIZE: usize = 5; // we store the project names so they're not instantly dropped and deleted - let _projects: Vec> = (0..=page_size) + let _projects: Vec> = (0..=PAGE_SIZE) .map(|n| Project::with_prefix(format!("proj-page-{}", n)).create()) .collect(); cloudtruth!("proj ls") .rest_debug() - .page_size(page_size) + .page_size(PAGE_SIZE) .assert() .success() - .paginated(page_size); + .paginated(PAGE_SIZE); } #[test] diff --git a/tests/test_templates.rs b/tests/test_templates.rs index 6da04a23d..f67442890 100644 --- a/tests/test_templates.rs +++ b/tests/test_templates.rs @@ -1085,3 +1085,22 @@ fn test_templates_ref_by_param() { assert_eq!("new-param-name = sample value", param.value); assert_eq!(format!("{{{{ cloudtruth.templates.{temp} }}}}"), param.raw); } + +#[test] +#[use_harness] +fn test_templates_pagination() { + const PAGE_SIZE: usize = 5; + let proj = Project::with_prefix("temp-paged").create(); + let temp_file = TestFile::with_contents("Nothing to evaluate here").unwrap(); + for i in 0..=PAGE_SIZE { + cloudtruth!("--project '{proj}' template set temp-{i} -b {temp_file}") + .assert() + .success(); + } + cloudtruth!("--project '{proj}' template ls") + .rest_debug() + .page_size(PAGE_SIZE) + .assert() + .success() + .paginated(PAGE_SIZE); +}