Skip to content

Regenerate expected JSON

Craig Smith requested to merge craigmsmith_skip_some_expected_fields into main

What does this MR do?

During gitlab-org/gitlab#390908 (closed) I've found I've needed to refresh the expected JSON regularly.

This MR aims to make that update process easier by integrating it into the rspec tests.

This MR adds the environment variable REFRESH_EXPECTED. When the rspec tests are run with the variable set to true, the tests generate new JSON, replace the fields id, version, start_time and end_time with :SKIP: (so they aren't included in any comparison 1) and then copies them to the appropriate file in the qa/expect directory.

Adding :SKIP: to these fields will make JSON updates in the future easier to visually parse, as :SKIP: will remove some of the noise.

The MR also includes all the new expected JSON after the regeneration has run.

To run the regeneration

docker run -it --rm -v "$PWD:$PWD" -w "$PWD" \
  -e TMP_IMAGE=semgrep \
  -e REFRESH_EXPECTED=true \
  -v /var/run/docker.sock:/var/run/docker.sock \
  registry.gitlab.com/gitlab-org/security-products/analyzers/integration-test:stable rspec

What are the relevant issue numbers?

gitlab-org/gitlab#390908 (closed)

Does this MR meet the acceptance criteria?

Edited by Craig Smith

Merge request reports