Denys
09/07/2023, 12:19 PMigor.wojda
09/07/2023, 1:16 PMfun `module 'core' should not depend on any module whose name starts with 'feature_'`() {
Konsist
.scopeFromProject()
.files
.withModule("core")
.assertNot {
it.imports.any { import -> import.name.contains(".feature.") }
}
}
.. however there is a hidden assumption to make this work - declarations in each feature module have proper package e.g
"feature_abc"
(module name) -> com.myapp.feature.abc
(package for each declaration in given module)
Fortunately the above can be verified by another Konsist Test:
fun `files reside in package that is derived from module name`() {
Konsist.scopeFromProduction()
.files
.assert {
/*
module -> package name:
feature_meal_planner -> mealplanner
feature_caloric_calculator -> caloriccalculator
*/
val featurePackageName = it
.moduleName
.removePrefix("feature_")
.replace("_", "")
it.hasPackage("com.myapp.${featurePackageName}..")
}
}
BTW this is very interesting case, so we will try to implement it in the near future as a part of assertArchitecture