Skip to content

Commit 15c924d

Browse files
committed
Update tests to use PushFramesResult
1 parent 7ecd8c8 commit 15c924d

File tree

2 files changed

+22
-15
lines changed

2 files changed

+22
-15
lines changed

libsql/src/sync.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ struct InfoResult {
9898
current_generation: u32,
9999
}
100100

101+
#[derive(Debug)]
101102
struct PushFramesResult {
102103
max_frame_no: u32,
103104
baton: Option<String>,

libsql/src/sync/test.rs

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ async fn test_sync_context_push_frame() {
2828
let mut sync_ctx = sync_ctx;
2929

3030
// Push a frame and verify the response
31-
let durable_frame = sync_ctx.push_frames(frame, 1, 0, 1).await.unwrap();
31+
let durable_frame = sync_ctx.push_frames(frame, 1, 0, 1, None).await.unwrap();
3232
sync_ctx.write_metadata().await.unwrap();
33-
assert_eq!(durable_frame, 0); // First frame should return max_frame_no = 0
33+
assert_eq!(durable_frame.max_frame_no, 0); // First frame should return max_frame_no = 0
3434

3535
// Verify internal state was updated
3636
assert_eq!(sync_ctx.durable_frame_num(), 0);
@@ -56,9 +56,9 @@ async fn test_sync_context_with_auth() {
5656
let frame = Bytes::from("test frame with auth");
5757
let mut sync_ctx = sync_ctx;
5858

59-
let durable_frame = sync_ctx.push_frames(frame, 1, 0, 1).await.unwrap();
59+
let durable_frame = sync_ctx.push_frames(frame, 1, 0, 1, None).await.unwrap();
6060
sync_ctx.write_metadata().await.unwrap();
61-
assert_eq!(durable_frame, 0);
61+
assert_eq!(durable_frame.max_frame_no, 0);
6262
assert_eq!(server.frame_count(), 1);
6363
}
6464

@@ -82,9 +82,9 @@ async fn test_sync_context_multiple_frames() {
8282
// Push multiple frames and verify incrementing frame numbers
8383
for i in 0..3 {
8484
let frame = Bytes::from(format!("frame data {}", i));
85-
let durable_frame = sync_ctx.push_frames(frame, 1, i, 1).await.unwrap();
85+
let durable_frame = sync_ctx.push_frames(frame, 1, i, 1, None).await.unwrap();
8686
sync_ctx.write_metadata().await.unwrap();
87-
assert_eq!(durable_frame, i);
87+
assert_eq!(durable_frame.max_frame_no, i);
8888
assert_eq!(sync_ctx.durable_frame_num(), i);
8989
assert_eq!(server.frame_count(), i + 1);
9090
}
@@ -108,9 +108,9 @@ async fn test_sync_context_corrupted_metadata() {
108108

109109
let mut sync_ctx = sync_ctx;
110110
let frame = Bytes::from("test frame data");
111-
let durable_frame = sync_ctx.push_frames(frame, 1, 0, 1).await.unwrap();
111+
let durable_frame = sync_ctx.push_frames(frame, 1, 0, 1, None).await.unwrap();
112112
sync_ctx.write_metadata().await.unwrap();
113-
assert_eq!(durable_frame, 0);
113+
assert_eq!(durable_frame.max_frame_no, 0);
114114
assert_eq!(server.frame_count(), 1);
115115

116116
// Update metadata path to use -info instead of .meta
@@ -152,9 +152,12 @@ async fn test_sync_restarts_with_lower_max_frame_no() {
152152

153153
let mut sync_ctx = sync_ctx;
154154
let frame = Bytes::from("test frame data");
155-
let durable_frame = sync_ctx.push_frames(frame.clone(), 1, 0, 1).await.unwrap();
155+
let durable_frame = sync_ctx
156+
.push_frames(frame.clone(), 1, 0, 1, None)
157+
.await
158+
.unwrap();
156159
sync_ctx.write_metadata().await.unwrap();
157-
assert_eq!(durable_frame, 0);
160+
assert_eq!(durable_frame.max_frame_no, 0);
158161
assert_eq!(server.frame_count(), 1);
159162

160163
// Bump the durable frame num so that the next time we call the
@@ -180,14 +183,17 @@ async fn test_sync_restarts_with_lower_max_frame_no() {
180183
// This push should fail because we are ahead of the server and thus should get an invalid
181184
// frame no error.
182185
sync_ctx
183-
.push_frames(frame.clone(), 1, frame_no, 1)
186+
.push_frames(frame.clone(), 1, frame_no, 1, None)
184187
.await
185188
.unwrap_err();
186189

187190
let frame_no = sync_ctx.durable_frame_num() + 1;
188191
// This then should work because when the last one failed it updated our state of the server
189192
// durable_frame_num and we should then start writing from there.
190-
sync_ctx.push_frames(frame, 1, frame_no, 1).await.unwrap();
193+
sync_ctx
194+
.push_frames(frame, 1, frame_no, 1, None)
195+
.await
196+
.unwrap();
191197
}
192198

193199
#[tokio::test]
@@ -215,7 +221,7 @@ async fn test_sync_context_retry_on_error() {
215221
server.return_error.store(true, Ordering::SeqCst);
216222

217223
// First attempt should fail but retry
218-
let result = sync_ctx.push_frames(frame.clone(), 1, 0, 1).await;
224+
let result = sync_ctx.push_frames(frame.clone(), 1, 0, 1, None).await;
219225
assert!(result.is_err());
220226

221227
// Advance time to trigger retries faster
@@ -228,9 +234,9 @@ async fn test_sync_context_retry_on_error() {
228234
server.return_error.store(false, Ordering::SeqCst);
229235

230236
// Next attempt should succeed
231-
let durable_frame = sync_ctx.push_frames(frame, 1, 0, 1).await.unwrap();
237+
let durable_frame = sync_ctx.push_frames(frame, 1, 0, 1, None).await.unwrap();
232238
sync_ctx.write_metadata().await.unwrap();
233-
assert_eq!(durable_frame, 0);
239+
assert_eq!(durable_frame.max_frame_no, 0);
234240
assert_eq!(server.frame_count(), 1);
235241
}
236242

0 commit comments

Comments
 (0)