Skip to content

Commit

Permalink
test: add integration test for admin desc
Browse files Browse the repository at this point in the history
  • Loading branch information
tmyoda committed Aug 31, 2023
1 parent 0350e39 commit 4d74ffc
Showing 1 changed file with 86 additions and 0 deletions.
86 changes: 86 additions & 0 deletions tests/admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,89 @@ async fn test_create_table_with_region_local_and_port_number_options(

util::cleanup_with_port(vec![table_name], port).await
}

#[tokio::test]
async fn test_admin_desc_table_from_options() -> Result<(), Box<dyn std::error::Error>> {
let table_name = util::create_temporary_table("pk,S", Some("sk,N")).await?;
let mut c = util::setup().await?;
let cmd = c.args(&["--region", "local", "admin", "--table", &table_name, "desc"]);
cmd.assert().success().stdout(
predicate::str::is_match(format!(
"name: {}
region: local
status: ACTIVE
schema:
pk: pk \\(S\\)
sk: sk \\(N\\)
mode: OnDemand
capacity: ~
gsi: ~
lsi: ~
stream: ~
count: 0
size_bytes: 0
created_at: \".*\"",
table_name
))
.unwrap(),
);
util::cleanup(vec![&table_name]).await
}

#[tokio::test]
async fn test_admin_desc_table_from_args() -> Result<(), Box<dyn std::error::Error>> {
let table_name = util::create_temporary_table("pk,S", Some("sk,N")).await?;

let mut c = util::setup().await?;
let cmd = c.args(&["--region", "local", "admin", "desc", &table_name]);
cmd.assert().success().stdout(
predicate::str::is_match(format!(
"name: {}
region: local
status: ACTIVE
schema:
pk: pk \\(S\\)
sk: sk \\(N\\)
mode: OnDemand
capacity: ~
gsi: ~
lsi: ~
stream: ~
count: 0
size_bytes: 0
created_at: \".*\"",
table_name
))
.unwrap(),
);
util::cleanup(vec![&table_name]).await
}

#[tokio::test]
async fn test_admin_desc_all_tables() -> Result<(), Box<dyn std::error::Error>> {
let table_name = util::create_temporary_table("pk", None).await?;

let mut c = util::setup().await?;
let cmd = c.args(&["--region", "local", "admin", "desc", "--all-tables"]);
cmd.assert().success().stdout(
predicate::str::is_match(format!(
"name: {}
region: local
status: ACTIVE
schema:
pk: pk \\(S\\)
sk: ~
mode: OnDemand
capacity: ~
gsi: ~
lsi: ~
stream: ~
count: 0
size_bytes: 0
created_at: \".*\"",
table_name
))
.unwrap(),
);
util::cleanup(vec![&table_name]).await
}

0 comments on commit 4d74ffc

Please sign in to comment.