Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

template pagination test #535

Merged
merged 1 commit into from
Jul 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions tests/test_environments.rs
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down Expand Up @@ -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<Scope<Environment>> = (0..=page_size)
let _envs: Vec<Scope<Environment>> = (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]
Expand Down Expand Up @@ -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]
Expand Down
10 changes: 4 additions & 6 deletions tests/test_projects.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
use cloudtruth_test_harness::prelude::*;

const TEST_PAGE_SIZE: usize = 5;

#[test]
#[use_harness]
fn test_projects_basic() {
Expand Down Expand Up @@ -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<Scope<Project>> = (0..=page_size)
let _projects: Vec<Scope<Project>> = (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]
Expand Down
19 changes: 19 additions & 0 deletions tests/test_templates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Loading