You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

41 lines
1.9 KiB

package com.mydreamjob.talentdiscovery;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.test.context.ActiveProfiles;
import static org.assertj.core.api.Assertions.assertThat;
/** 只读确认 V41 的 V39 迁移在集成测试 H2(MODE=MySQL) 中已执行。 */
@SpringBootTest
@ActiveProfiles("integration-test")
class TalentDiscoveryPersistenceIntegrationTest {
@Autowired JdbcTemplate jdbcTemplate;
@MockBean RedisTemplate<String, Object> redisTemplate;
@Test
void v39Migration_createsPreferenceTableWithSafeDefaultsAndConstraints() {
Integer tableCount = jdbcTemplate.queryForObject(
"SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='STUDENT_TALENT_DISCOVERY_PREFERENCES'",
Integer.class);
assertThat(tableCount).isEqualTo(1);
String enabledDefault = jdbcTemplate.queryForObject(
"SELECT COLUMN_DEFAULT FROM INFORMATION_SCHEMA.COLUMNS "
+ "WHERE TABLE_NAME='STUDENT_TALENT_DISCOVERY_PREFERENCES' AND COLUMN_NAME='ENABLED'",
String.class);
assertThat(enabledDefault).isEqualTo("0");
Integer uniqueCount = jdbcTemplate.queryForObject(
"SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS "
+ "WHERE TABLE_NAME='STUDENT_TALENT_DISCOVERY_PREFERENCES' "
+ "AND CONSTRAINT_NAME='UK_STUDENT_TALENT_DISCOVERY_PREFERENCES_STUDENT' "
+ "AND CONSTRAINT_TYPE='UNIQUE'",
Integer.class);
assertThat(uniqueCount).isEqualTo(1);
}
}