Repository: 7mind/izumi
Pull request #1116 (2020-06-17 14:41:53)

distage-testkit: Add `TestConfig#bootstrapFactory` configuration
* add `Activation#+`

codecov-commenter: # [Codecov](https://codecov.io/gh/7mind/izumi/pull/1116?src=pr&el=h1) Report
> Merging [#1116](https://codecov.io/gh/7mind/izumi/pull/1116?src=pr&el=desc) into [develop](https://codecov.io/gh/7mind/izumi/commit/3ac70a61836e8536604124284bf701e7fe109b9f&el=desc) will **decrease** coverage by `0.04%`.
> The diff coverage is `40.00%`.


```diff
@@             Coverage Diff             @@
##           develop    #1116      +/-   ##
===========================================
- Coverage    61.04%   61.00%   -0.05%     
===========================================
  Files          384      384              
  Lines         7142     7144       +2     
  Branches       353      352       -1     
===========================================
- Hits          4360     4358       -2     
- Misses        2782     2786       +4     
```


Patch:
diff --git a/distage/distage-core-api/src/main/scala/izumi/distage/model/definition/Activation.scala b/distage/distage-core-api/src/main/scala/izumi/distage/model/definition/Activation.scala
index f02e09ad8..058b951be 100644
--- a/distage/distage-core-api/src/main/scala/izumi/distage/model/definition/Activation.scala
+++ b/distage/distage-core-api/src/main/scala/izumi/distage/model/definition/Activation.scala
@@ -4,9 +4,11 @@ import izumi.distage.model.definition.Axis.AxisValue
 
 final case class Activation(activeChoices: Map[Axis, AxisValue]) extends AnyVal {
   @inline def ++(activation: Activation): Activation = Activation(activeChoices ++ activation.activeChoices)
+  @inline def +(axisChoice: (Axis, AxisValue)): Activation = this ++ Activation(axisChoice._1 -> axisChoice._2)
 }
 
 object Activation {
   def apply(activeChoices: (Axis, AxisValue)*): Activation = Activation(Map(activeChoices: _*))
+  def apply(): Activation = empty
   val empty: Activation = new Activation(Map.empty)
 }


Test patch:
diff --git a/distage/distage-testkit-core/src/main/scala/izumi/distage/testkit/TestConfig.scala b/distage/distage-testkit-core/src/main/scala/izumi/distage/testkit/TestConfig.scala
index edf632707..9cef03d50 100644
--- a/distage/distage-testkit-core/src/main/scala/izumi/distage/testkit/TestConfig.scala
+++ b/distage/distage-testkit-core/src/main/scala/izumi/distage/testkit/TestConfig.scala
@@ -5,6 +5,7 @@ import distage.{Activation, BootstrapModule, DIKey, Module, StandardAxis}
 import izumi.distage.framework.config.PlanningOptions
 import izumi.distage.plugins.PluginConfig
 import izumi.distage.testkit.TestConfig.ParallelLevel
+import izumi.distage.testkit.services.dstest.BootstrapFactory
 import izumi.logstage.api.Log
 
 /**
@@ -69,6 +70,8 @@ import izumi.logstage.api.Log
   *
   * @param configOverrides       Overriding definitions on top of main loaded config, default `None`
   *
+  * @param bootstrapFactory      [[BootstrapFactory]], controls config loading & initial modules
+
   * @param planningOptions       [[PlanningOptions]], debug options for [[distage.Planner]]
   *
   * @param logLevel              Log level for the [[logstage.IzLogger]] used in testkit and provided to the tests (will be overriden by plugin / module bindings if exist)
@@ -93,6 +96,7 @@ final case class TestConfig(
   // other options
   configBaseName: String,
   configOverrides: Option[AppConfig] = None,
+  bootstrapFactory: BootstrapFactory = BootstrapFactory.Impl,
   planningOptions: PlanningOptions = PlanningOptions(),
   logLevel: Log.Level = Log.Level.Info,
   debugOutput: Boolean = false,
diff --git a/distage/distage-testkit-core/src/main/scala/izumi/distage/testkit/services/dstest/DistageTestEnv.scala b/distage/distage-testkit-core/src/main/scala/izumi/distage/testkit/services/dstest/DistageTestEnv.scala
index 51cc6ea0e..37d263381 100644
--- a/distage/distage-testkit-core/src/main/scala/izumi/distage/testkit/services/dstest/DistageTestEnv.scala
+++ b/distage/distage-testkit-core/src/main/scala/izumi/distage/testkit/services/dstest/DistageTestEnv.scala
@@ -39,7 +39,6 @@ trait DistageTestEnv {
     val appModule = mergeStrategy.merge(appPlugins) overridenBy testConfig.moduleOverrides
     val bootstrapModule = mergeStrategy.merge(bsPlugins) overridenBy testConfig.bootstrapOverrides
     val availableActivations = ActivationInfoExtractor.findAvailableChoices(appModule)
-    val activation = testConfig.activation
 
     val bsModule = bootstrapModule overridenBy new BootstrapModuleDef {
         make[PlanMergingPolicy].from[PruningPlanMergingPolicyLoggedImpl]
@@ -51,11 +50,11 @@ trait DistageTestEnv {
       appModule = appModule,
       roles = roles,
       activationInfo = availableActivations,
-      activation = activation,
+      activation = testConfig.activation,
       memoizationRoots = testConfig.memoizationRoots.toSet,
       forcedRoots = testConfig.forcedRoots.toSet,
       parallelEnvs = testConfig.parallelEnvs,
-      bootstrapFactory = BootstrapFactory.Impl,
+      bootstrapFactory = testConfig.bootstrapFactory,
       configBaseName = testConfig.configBaseName,
       configOverrides = testConfig.configOverrides,
       planningOptions = testConfig.planningOptions,
diff --git a/distage/distage-testkit-core/src/main/scala/izumi/distage/testkit/services/dstest/DistageTestRunner.scala b/distage/distage-testkit-core/src/main/scala/izumi/distage/testkit/services/dstest/DistageTestRunner.scala
index 5059b03f4..1db9937df 100644
--- a/distage/distage-testkit-core/src/main/scala/izumi/distage/testkit/services/dstest/DistageTestRunner.scala
+++ b/distage/distage-testkit-core/src/main/scala/izumi/distage/testkit/services/dstest/DistageTestRunner.scala
@@ -447,12 +447,12 @@ class DistageTestRunner[F[_]: TagK](
             .bootstrapFactory
             .makeConfigLoader(env.configBaseName, envLogger)
             .map {
-              c =>
+              appConfig =>
                 env.configOverrides match {
                   case Some(overrides) =>
-                    AppConfig(overrides.config.withFallback(c.config).resolve())
+                    AppConfig(overrides.config.withFallback(appConfig.config).resolve())
                   case None =>
-                    c
+                    appConfig
                 }
             }
           configLoader.loadConfig()