refactor: Extract a unit test for case 1

Also add coverage for when there are no *partitions* in addition to the
test for when there are no *parquet files*.
pull/24376/head
Carol (Nichols || Goulding) 2022-09-16 17:46:10 -04:00
parent 9372290ec9
commit d95f252a8e
No known key found for this signature in database
GPG Key ID: E907EE5A736F87D4
1 changed files with 43 additions and 8 deletions

View File

@ -251,6 +251,49 @@ mod tests {
}
}
#[tokio::test]
async fn no_partitions_no_candidates() {
let TestSetup {
catalog, shard1, ..
} = test_setup().await;
let candidates = hot_partitions_for_shard(
Arc::clone(&catalog.catalog),
shard1.shard.id,
&query_times(catalog.time_provider()),
1,
1,
)
.await
.unwrap();
assert!(candidates.is_empty());
}
#[tokio::test]
async fn no_files_no_candidates() {
let TestSetup {
catalog,
shard1,
table1,
..
} = test_setup().await;
table1.with_shard(&shard1).create_partition("one").await;
let candidates = hot_partitions_for_shard(
Arc::clone(&catalog.catalog),
shard1.shard.id,
&query_times(catalog.time_provider()),
1,
1,
)
.await
.unwrap();
assert!(candidates.is_empty());
}
#[tokio::test]
async fn test_hot_partitions_to_compact() {
let TestSetup {
@ -299,14 +342,6 @@ mod tests {
// In order words, the last Case needs all content of previous tests.
// This shows the priority of selecting compaction candidates
// --------------------------------------
// Case 1: no files yet --> no partition candidates
//
let candidates = hot_partitions_to_compact(Arc::clone(&compactor))
.await
.unwrap();
assert!(candidates.is_empty());
// --------------------------------------
// Case 2: no non-deleleted L0 files --> no partition candidates
//