test(content): 覆盖免费集数未变但分集漂移的修复场景
This commit is contained in:
1 parent
b8b3fd867b
commit
8bb7f63c62
1 file changed
+21
-1
+21
-1
@@ -122,10 +122,30 @@ class DramaServiceTest {
|
|||||||
dramaService.update(DRAMA_ID, saveReq(3, UNLOCK_COIN));
|
dramaService.update(DRAMA_ID, saveReq(3, UNLOCK_COIN));
|
||||||
|
|
||||||
assertThat(episodeUpdates.get()).isZero();
|
assertThat(episodeUpdates.get()).isZero();
|
||||||
verify(dramaEpisodeMapper, never()).selectList(any());
|
verify(dramaEpisodeMapper, times(1)).selectList(any());
|
||||||
verify(dramaEpisodeMapper, never()).updateById(any(DramaEpisode.class));
|
verify(dramaEpisodeMapper, never()).updateById(any(DramaEpisode.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 历史漂移:短剧 freeEpisodes/unlockCoin 已是目标值,但分集 is_free 仍是旧规则。
|
||||||
|
* 同值重存必须纠偏,不能因「规则字段未变」短路跳过同步。
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
void should_correct_drifted_episode_is_free_when_free_episodes_and_unlock_coin_unchanged() {
|
||||||
|
givenExistingDrama(9, UNLOCK_COIN);
|
||||||
|
// 规则已是免费 9 集,分集仍按旧规则只免费到第 4 集(5~9 仍收费)
|
||||||
|
seedEpisodesAlignedToFree(4, 9);
|
||||||
|
|
||||||
|
dramaService.update(DRAMA_ID, saveReq(9, UNLOCK_COIN));
|
||||||
|
|
||||||
|
Map<Integer, DramaEpisode> byEpNo = episodeMap();
|
||||||
|
for (int epNo = 1; epNo <= 9; epNo++) {
|
||||||
|
assertThat(byEpNo.get(epNo).getIsFree()).isEqualTo(1);
|
||||||
|
assertThat(byEpNo.get(epNo).getUnlockCoin()).isZero();
|
||||||
|
}
|
||||||
|
verify(dramaEpisodeMapper, times(5)).updateById(any(DramaEpisode.class));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void should_not_fail_when_drama_has_no_episodes() {
|
void should_not_fail_when_drama_has_no_episodes() {
|
||||||
givenExistingDrama(3, UNLOCK_COIN);
|
givenExistingDrama(3, UNLOCK_COIN);
|
||||||
|
|||||||
Reference in new issue
Block a user