`Module.verify()` (koin 4.0.0) doesn’t report miss...
# koin
m
Module.verify()
(koin 4.0.0) doesn’t report missing dependency when binding to an interface. Even though in the following setup
dataStore
is not declared, the test passes.
Copy code
single<AuthRepository> {
    AuthRepositoryImpl(
       dataStore = get()
    )
}
In the test logs there is only this mention about
AuthRepository
:
Copy code
|-> definition [Singleton: 'com.example.koinscope.model.repositories.AuthRepository']
| bind types: [class com.example.koinscope.model.repositories.AuthRepository]
Does
verify
require additional setup to properly check the dependencies of the concrete implementations?
1
p
Migrate to Koin constructor dsl, in your module. And run the test again, please.
single(::AuthRepositoryImpl)
thank you color 1
m
@Pedro Francisco de Sousa Neto it worked, thanks for the pointer!
when retrieving a named definition the documentation hints at using the standard dsl, is there a way to make use of
verify
for that case?
p
Unhappily
verify
function just check your parameters if you're using Koin Constructor DSL. There is a lack of implementation, I guess. 😢 To check dependencies without migrating to constructor dsl you need to use the checkDependencies. But is deprecated. @arnaud.giuliani one more person suffering with this scenario again. FYI
😢 1
a
you would need to discouple the inner definition, from the bound type:
single {AuthRepositoryImpl(get()) } bind AuthRepository::class
thank you color 1
else verify can't find what's really under the hood for yoru definition
m
@arnaud.giuliani thanks! after making this change it checks the
dataStore
dependency. I’ve noticed that it doesn’t check if there is a declaration with that qualifier, only that there is a definition for that type, is this something currently missing? For ex:
Copy code
single {
        AuthRepositoryImpl(
            dataStore = get(named("myStore2"))
        )
    } bind AuthRepository::class
would pass, even if there is only a dataStore named
myStore1
declared.
a
yeah, the "named" param is not a static info ... in Koin Annotations you would be able to do so
👍 1