Skip to content

Commit 6171b1e

Browse files
HawaiianSporkLiam Brannigan
authored andcommitted
format and added asserts for new attributes on existing unit tests
Signed-off-by: Michael Maletich <[email protected]>
1 parent 16317ea commit 6171b1e

File tree

3 files changed

+48
-22
lines changed

3 files changed

+48
-22
lines changed

crates/core/src/kernel/snapshot/log_segment.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -829,6 +829,10 @@ pub(super) mod tests {
829829
.await
830830
.unwrap();
831831

832+
assert_eq!(commit.metrics.num_retries, 0);
833+
assert_eq!(commit.metrics.num_log_files_cleaned_up, 0);
834+
assert_eq!(commit.metrics.new_checkpoint_created, false);
835+
832836
let batches = LogSegment::try_new(
833837
&Path::default(),
834838
Some(commit.version),

crates/core/src/operations/transaction/mod.rs

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@ use serde_json::Value;
8686
use tracing::*;
8787
use uuid::Uuid;
8888

89+
pub use self::conflict_checker::CommitConflictError;
8990
use self::conflict_checker::{TransactionInfo, WinningCommitSummary};
91+
pub use self::protocol::INSTANCE as PROTOCOL;
9092
use crate::checkpoints::{cleanup_expired_logs_for, create_checkpoint_for};
9193
use crate::errors::DeltaTableError;
9294
use crate::kernel::{Action, CommitInfo, EagerSnapshot, Metadata, Protocol, Transaction};
@@ -98,8 +100,6 @@ use crate::table::state::DeltaTableState;
98100
use crate::{crate_version, DeltaResult};
99101
use delta_kernel::table_features::{ReaderFeatures, WriterFeatures};
100102
use serde::{Deserialize, Serialize};
101-
pub use self::conflict_checker::CommitConflictError;
102-
pub use self::protocol::INSTANCE as PROTOCOL;
103103

104104
use super::CustomExecuteHandler;
105105

@@ -783,16 +783,17 @@ impl PostCommit<'_> {
783783
let mut new_checkpoint_created = false;
784784
if self.create_checkpoint {
785785
// Execute create checkpoint hook
786-
new_checkpoint_created = self.create_checkpoint(
787-
&state,
788-
&self.log_store,
789-
self.version,
790-
post_commit_operation_id,
791-
)
792-
.await?;
786+
new_checkpoint_created = self
787+
.create_checkpoint(
788+
&state,
789+
&self.log_store,
790+
self.version,
791+
post_commit_operation_id,
792+
)
793+
.await?;
793794
}
794795

795-
let mut num_log_files_cleaned_up : u64 = 0;
796+
let mut num_log_files_cleaned_up: u64 = 0;
796797
if cleanup_logs {
797798
// Execute clean up logs hook
798799
num_log_files_cleaned_up = cleanup_expired_logs_for(
@@ -815,10 +816,13 @@ impl PostCommit<'_> {
815816
)
816817
.await?
817818
}
818-
Ok((state, PostCommitMetrics {
819-
new_checkpoint_created,
820-
num_log_files_cleaned_up,
821-
}))
819+
Ok((
820+
state,
821+
PostCommitMetrics {
822+
new_checkpoint_created,
823+
num_log_files_cleaned_up,
824+
},
825+
))
822826
} else {
823827
let state = DeltaTableState::try_new(
824828
&Path::default(),
@@ -827,10 +831,13 @@ impl PostCommit<'_> {
827831
Some(self.version),
828832
)
829833
.await?;
830-
Ok((state, PostCommitMetrics {
831-
new_checkpoint_created: false,
832-
num_log_files_cleaned_up: 0,
833-
}))
834+
Ok((
835+
state,
836+
PostCommitMetrics {
837+
new_checkpoint_created: false,
838+
num_log_files_cleaned_up: 0,
839+
},
840+
))
834841
}
835842
}
836843
async fn create_checkpoint(

crates/core/src/protocol/checkpoints.rs

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -654,18 +654,33 @@ mod tests {
654654
query_id: "test".into(),
655655
epoch_id,
656656
};
657-
let v = CommitBuilder::default()
657+
let finalized_commit = CommitBuilder::default()
658658
.with_actions(actions)
659659
.build(
660660
table.state.as_ref().map(|f| f as &dyn TableReference),
661661
table.log_store(),
662662
operation,
663663
)
664664
.await
665-
.unwrap()
666-
.version();
665+
.unwrap();
667666

668-
assert_eq!(1, v, "Expected the commit to create table version 1");
667+
assert_eq!(
668+
1,
669+
finalized_commit.version(),
670+
"Expected the commit to create table version 1"
671+
);
672+
assert_eq!(
673+
0, finalized_commit.metrics.num_retries,
674+
"Expected no retries"
675+
);
676+
assert_eq!(
677+
0, finalized_commit.metrics.num_log_files_cleaned_up,
678+
"Expected no log files cleaned up"
679+
);
680+
assert_eq!(
681+
false, finalized_commit.metrics.new_checkpoint_created,
682+
"Expected checkpoint created."
683+
);
669684
table.load().await.expect("Failed to reload table");
670685
assert_eq!(
671686
table.version(),

0 commit comments

Comments
 (0)