Skip to content

Commit

Permalink
Copy from TransactionLogPartitionStoreTest to TransactionLogPartition…
Browse files Browse the repository at this point in the history
…StoreIT
  • Loading branch information
patchwork01 committed Feb 21, 2025
1 parent 6d0bf45 commit 94b879a
Showing 1 changed file with 36 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ void shouldReinitialisePartitionsWhenNoFilesArePresent() {
initialiseWithPartitions(partitionsBefore);

// When
store.initialise(partitionsAfter.buildList());
update(store).initialise(partitionsAfter.buildList());

// Then
assertThat(store.getAllPartitions())
Expand All @@ -215,7 +215,7 @@ void shouldNotReinitialisePartitionsWhenAFileIsPresent() {
update(store).addFile(factory.partitionFile("before2", 100L));

// When / Then
assertThatThrownBy(() -> store.initialise(partitionsAfter.buildList()))
assertThatThrownBy(() -> update(store).initialise(partitionsAfter.buildList()))
.isInstanceOf(StateStoreException.class);
assertThat(store.getAllPartitions())
.containsExactlyInAnyOrderElementsOf(partitionsBefore.buildList());
Expand Down Expand Up @@ -353,4 +353,38 @@ public void shouldFailSplittingAPartitionWhenNewPartitionIsNotALeaf() {
.isInstanceOf(StateStoreException.class);
}
}

@Nested
@DisplayName("Clear partitions")
class ClearPartitions {
@Test
void shouldDeleteSinglePartitionOnClear() {
// Given
Schema schema = schemaWithKey("key", new IntType());
initialiseWithSchema(schema);

// When
update(store).clearSleeperTable();

// Then
assertThat(store.getAllPartitions()).isEmpty();
assertThat(store.getLeafPartitions()).isEmpty();
}

@Test
void shouldDeletePartitionTreeOnClear() {
// Given
Schema schema = schemaWithKey("key", new IntType());
initialiseWithPartitions(new PartitionsBuilder(schema)
.rootFirst("root")
.splitToNewChildren("root", "L", "R", 123));

// When
update(store).clearSleeperTable();

// Then
assertThat(store.getAllPartitions()).isEmpty();
assertThat(store.getLeafPartitions()).isEmpty();
}
}
}

0 comments on commit 94b879a

Please sign in to comment.