From aa0edc23bf435688476be3ded8c699a11986d4b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Galkin?= Date: Mon, 2 Dec 2024 18:17:35 -0300 Subject: [PATCH] Add some rebase test assertions (#431) --- icechunk/src/repository.rs | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/icechunk/src/repository.rs b/icechunk/src/repository.rs index b351b66da..f5b77c54c 100644 --- a/icechunk/src/repository.rs +++ b/icechunk/src/repository.rs @@ -2703,16 +2703,27 @@ mod tests { .set_chunk_ref( new_array_path.clone(), ChunkIndices(vec![0]), - Some(ChunkPayload::Inline("hello".into())), + Some(ChunkPayload::Inline("hello0".into())), ) .await?; repo1 .set_chunk_ref( new_array_path.clone(), ChunkIndices(vec![1]), - Some(ChunkPayload::Inline("hello".into())), + Some(ChunkPayload::Inline("hello1".into())), ) .await?; + + let new_array_2_path: Path = "/array_2".try_into().unwrap(); + repo1.add_array(new_array_2_path.clone(), zarr_meta.clone()).await?; + repo1 + .set_chunk_ref( + new_array_2_path.clone(), + ChunkIndices(vec![0]), + Some(ChunkPayload::Inline("bye0".into())), + ) + .await?; + let conflicting_snap = repo1.commit("main", "write two chunks with repo 1", None).await?; @@ -2724,7 +2735,7 @@ mod tests { .set_chunk_ref( new_array_path.clone(), ChunkIndices(vec![2]), - Some(ChunkPayload::Inline("hello".into())), + Some(ChunkPayload::Inline("hello2".into())), ) .await?; if let Err(RepositoryError::Conflict { .. }) = @@ -2736,7 +2747,21 @@ mod tests { repo2.commit("main", "after conflict", None).await?; let data = repo2.get_chunk_ref(&new_array_path, &ChunkIndices(vec![2])).await?; - assert_eq!(data, Some(ChunkPayload::Inline("hello".into()))); + assert_eq!(data, Some(ChunkPayload::Inline("hello2".into()))); + + // other chunks written by the conflicting commit are still there + let data = + repo2.get_chunk_ref(&new_array_path, &ChunkIndices(vec![0])).await?; + assert_eq!(data, Some(ChunkPayload::Inline("hello0".into()))); + let data = + repo2.get_chunk_ref(&new_array_path, &ChunkIndices(vec![1])).await?; + assert_eq!(data, Some(ChunkPayload::Inline("hello1".into()))); + + // new arrays written by the conflicting commit are still there + let data = + repo2.get_chunk_ref(&new_array_2_path, &ChunkIndices(vec![0])).await?; + assert_eq!(data, Some(ChunkPayload::Inline("bye0".into()))); + let commits = repo2.ancestry().await?.try_collect::>().await?; assert_eq!(commits[0].message, "after conflict"); assert_eq!(commits[1].message, "write two chunks with repo 1"); @@ -2864,7 +2889,7 @@ mod tests { repo2.commit("main", "after conflict", None).await?; let data = repo2.get_chunk_ref(&new_array_path, &ChunkIndices(vec![1])).await?; - assert_eq!(data, Some(ChunkPayload::Inline("hello".into()))); + assert_eq!(data, Some(ChunkPayload::Inline("hello1".into()))); let commits = repo2.ancestry().await?.try_collect::>().await?; assert_eq!(commits[0].message, "after conflict"); assert_eq!(commits[1].message, "write two chunks with repo 1");