Last active
November 21, 2024 23:08
-
-
Save vladdedita/ae4cdd3a7c8cf702d6445fcba01524ca to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ExtendWith(PostgreSQLExtension.class) | |
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, properties = { | |
// We need to enable lazy initialization to avoid the EntityManager creation during the context loading | |
"spring.main.lazy-initialization=true" | |
}) | |
class CleanPostgreSQLTest { | |
@Autowired | |
EntityManager entityManager; | |
@Test | |
void test() { | |
// Query data | |
var result = entityManager.createNativeQuery("SELECT COUNT(*) FROM public.user").getSingleResult(); | |
assertThat(result).isEqualTo(2L); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment