Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A more elegant way to disable transactions for kotest "globally" #676

Open
adamkobor opened this issue Nov 17, 2022 · 1 comment
Open

A more elegant way to disable transactions for kotest "globally" #676

adamkobor opened this issue Nov 17, 2022 · 1 comment

Comments

@adamkobor
Copy link
Contributor

adamkobor commented Nov 17, 2022

Feature description

The problem is that micronaut-data starting with version 3.8.0 throws an error if we simply use the@MicronautTest annotation without explicitly setting transactional to false when the configured data source is a reactive one (i.e. R2DBC). AFAIK this is a shortcoming of Kotest that it can't handle reactive transactions and not something that should/could be configured correctly to make it work, so it would be great if there would be a way to omit these verbose transactional=false arguments if we use R2DBC with Kotest.

Something like this would do the job without making any breaking change, but I'm not sure if this is the right approach:

object MicronautKotestExtension : MicronautKotestExtensionImpl(false)
object MicronautKotestReactiveExtension : MicronautKotestExtensionImpl(true)

open class MicronautKotestExtensionImpl(
    private val withReactiveData: Boolean
) : TestListener, ConstructorExtension, TestCaseExtension {
// ...
private fun buildValueObject(micronautTest: MicronautTest): MicronautTestValue {
        return MicronautTestValue(
            micronautTest.application.java,
            micronautTest.environments,
            micronautTest.packages,
            micronautTest.propertySources,
            micronautTest.rollback,
            if (withReactiveData) false else micronautTest.transactional,
            micronautTest.rebuildContext,
            micronautTest.contextBuilder.map { kClass -> kClass.java }.toTypedArray(),
            micronautTest.transactionMode,
            micronautTest.startApplication
        )
    }
// ...
}

Then everybody could decide if they would like to use the "old" MicronautKotestExtension that would behave the same way as it used to, or use the new one that would change the transactional property to false internally.

Related to #669

@adamkobor
Copy link
Contributor Author

bump

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant