8000 Better support for Spring Boot's @DataMongoTest · Issue #551 · mongock/mongock · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Better support for Spring Boot's @DataMongoTest #551
Open
@rfelgent

Description

@rfelgent

Hello,

mongock gets triggered in a test without any problem when performing a fully fledged spring boot test e.g.

@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
@Testcontainers   // spinning up mongdb container by testcontainers library
class ApplicationIT {
}

Mongock is failing when doing a mongo slice test

@DataMongoTest
@Import(MongockConfig.class)   // a dedicated config class for mongock stuff like `@EnableMongock` and other beans that are only required for mongock migration stuff
@Testcontainers // spinning up mongdb container by testcontainers library
class RepositoryIT {
}

I found a way to fix this by manually adding a driver bean to the spring context

@TestConfiguration
  static class Fixture {

    @Bean
    public SpringDataMongoV3Driver driver(@Autowired MongoTemplate mongoTemplate) {
      return SpringDataMongoV3Driver.withDefaultLock(mongoTemplate);
    }

  }

So I do observe that Mongock's autoconfiguration for "driver" beans is failing within a @DataMongoTest.
I am using SB 2.7 and SB 2.6.X and only the Mongock version is 5.1.0

Best regards

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0