ManaMatrix commented on code in PR #28842:
URL: https://github.com/apache/shardingsphere/pull/28842#discussion_r1368359540
##########
test/it/pipeline/src/test/java/org/apache/shardingsphere/test/it/data/pipeline/core/job/service/GovernanceRepositoryAPIImplTest.java:
##########
@@ -155,7 +153,39 @@ void assertPersistJobOffsetInfo() {
assertTrue(actual.isPresent());
assertThat(actual.get(), is("testValue"));
}
-
+
+ @Test
+ void assertPersistLatestCheckJobId() {
+ String parentJobId = "parentJob123";
+ String checkJobId = "checkJob456";
+ governanceRepositoryAPI.persistLatestCheckJobId(parentJobId,
checkJobId);
+ Optional<String> retrievedCheckJobId =
governanceRepositoryAPI.getLatestCheckJobId(parentJobId);
+ assertTrue(retrievedCheckJobId.isPresent(), "Expected a checkJobId to
be present");
+ assertEquals(retrievedCheckJobId.get(), checkJobId, "The retrieved
checkJobId does not match the persisted one");
+ }
+
+ @Test
+ void assertGetLatestCheckJobId() {
+ String parentJobId = "parentJob789";
+ String checkJobId = "checkJob012";
+ governanceRepositoryAPI.persistLatestCheckJobId(parentJobId,
checkJobId);
+ Optional<String> retrievedCheckJobId =
governanceRepositoryAPI.getLatestCheckJobId(parentJobId);
+ assertTrue(retrievedCheckJobId.isPresent(), "Expected a checkJobId to
be present");
+ assertEquals(checkJobId, retrievedCheckJobId.get(), "The retrieved
checkJobId does not match the expected one");
+ governanceRepositoryAPI.deleteLatestCheckJobId(parentJobId);
+
assertFalse(governanceRepositoryAPI.getLatestCheckJobId(parentJobId).isPresent(),
"Expected no checkJobId to be present after deletion");
+ }
+
+ @Test
+ void assertDeleteLatestCheckJobId() {
+ String parentJobId = "parentJob123";
+ String checkJobId = "checkJob456";
+ governanceRepositoryAPI.persistLatestCheckJobId(parentJobId,
checkJobId);
+
assertTrue(governanceRepositoryAPI.getLatestCheckJobId(parentJobId).isPresent(),
"Expected checkJobId to be present before deletion");
+ governanceRepositoryAPI.deleteLatestCheckJobId(parentJobId);
+
assertFalse(governanceRepositoryAPI.getLatestCheckJobId(parentJobId).isPresent(),
"Expected no checkJobId to be present after deletion");
+ }
Review Comment:
It makes sense. Just combine them in one unit test method.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]