fix(firstleg): execute carrier schedule due queries

This commit is contained in:
2026-08-25 13:46:33 +08:00
parent 0302985f21
commit 72f3f9f971
2 changed files with 27 additions and 4 deletions
@@ -1,5 +1,8 @@
package com.baiyue.firstleg.portschedule.repository;
import com.baiyue.firstleg.portschedule.mapper.CarrierScheduleQueryMapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.junit.jupiter.api.Test;
import org.springframework.core.io.ClassPathResource;
@@ -10,6 +13,26 @@ import java.nio.file.Path;
import static org.assertj.core.api.Assertions.assertThat;
class CarrierScheduleQuerySqlContractTest {
@Test
void annotationSqlUsesExecutableComparisonOperators() throws Exception {
String selectDue = String.join("\n", CarrierScheduleQueryMapper.class
.getMethod("selectDue", java.time.LocalDateTime.class, int.class)
.getAnnotation(Select.class).value());
String claimLease = String.join("\n", CarrierScheduleQueryMapper.class
.getMethod("claimLease", long.class, String.class, java.time.LocalDateTime.class,
java.time.LocalDateTime.class)
.getAnnotation(Update.class).value());
assertThat(selectDue)
.contains("next_allowed_at <= #{now}")
.contains("lease_until < #{now}")
.doesNotContain("&lt;");
assertThat(claimLease)
.contains("next_allowed_at <= #{now}")
.contains("lease_until < #{now}")
.doesNotContain("&lt;");
}
@Test
void definesTaskAttemptsHistoryIdempotencyAndHardLimit() throws Exception {
assertThat(moduleSql())