diff --git a/DEVELOPING.md b/DEVELOPING.md index 5dd88e274..fd14963df 100644 --- a/DEVELOPING.md +++ b/DEVELOPING.md @@ -367,11 +367,11 @@ package under test and should always be updated by invoking `go test` on the spe update flag provided. Many of the `Format` tests make use of this approach, where the raw SBOM report is saved in the repo and the test -compares that SBOM with what is generated from the latest presenter code. For instance, at the time of this writing -the CycloneDX presenter snapshots can be updated by running: +compares that SBOM with what is generated from the latest presenter code. The following command can be used to +update the golden files for the various snapshot tests: ```bash -go test ./internal/formats -update-cyclonedx +make update-format-golden-files ``` These flags are defined at the top of the test files that have tests that use the snapshot files. diff --git a/Taskfile.yaml b/Taskfile.yaml index 5e7f2c000..248e2c8ee 100644 --- a/Taskfile.yaml +++ b/Taskfile.yaml @@ -191,6 +191,14 @@ tasks: ## Testing tasks ################################# + update-format-golden-files: + desc: "Update golden (i.e. snapshot) files used by unit tests" + cmds: + - go test ./syft/format/spdxjson -update-spdx-json + - go test ./syft/format/spdxtagvalue -update-spdx-tv + - go test ./syft/format/cyclonedxxml -update-cyclonedx-xml + - go test ./syft/format/cyclonedxjson -update-cyclonedx-json + - go test ./syft/format/syftjson -update-json unit: desc: Run unit tests