lundi 18 février 2019

Dependency Injection problem with versioning

Currently, we're migrating from v1 to v2 of our own code, the problem that we have is the following:

function A(){
  function methodAV1(){...}
}

function AV2(){
  function methodAV2(){...}
}

function Domain(AV1,AV2){
  function exec(){
    if(v2Enabled)
      AV1.methodAV1()
    else
      AV2.methodAV2()
  }
}

So the problem with this is that when the v2 is enabled everything works fine, but when I disable the v2, I need to mock AV2 so the dependency injection don't crash. I cannot separate it enterly cause the flow must be that when something couldn't work using the V2, must use the V1 to ensure a response. I don't know how to properly address this in order to don't have to mock a lot of V2 services when we keep working on them. Any advice could be useful, thanks a lot

Aucun commentaire:

Enregistrer un commentaire