Skip to content

fix: isolate Config changes in unit tests

Konstantin Gukov requested to merge msft/feat/update-sinon into master

Type of change

  • Bug Fix
  • Feature
  • Pipeline
  • Test
  • Documentation

Does this introduce a change in the core logic?

  • No
  • Yes

Does this introduce a change in the cloud provider implementation, if so which cloud?

  • AWS
  • Anthos
  • Azure
  • GCP
  • IBM

Does this follow conventional commits spec?

  • No
  • Yes

Have you set the target Milestone?

  • No
  • Yes

Have you set the no-detached-pipeline label?

  • No
  • Yes

Updates description?

Problem

There are multiple global variables, "configs", on which the business logic depends. They include Config, AzureConfig, ConfigGoogle.

Unit tests sometimes edit these configs when setting up in order to test the right business logic. However, they almost never perform a proper cleanup, and these changes in the global configs "leak" into the subsequent tests.

Solution

Use the new sinon.define method for any edits in the global configs. All such changes will be reverted after each test via the after-test hook with sandbox.restore().

Edited by Konstantin Gukov

Merge request reports