Skip to content

Conversation

pd93
Copy link
Member

@pd93 pd93 commented May 20, 2025

Followup to the style of test that was added in #2256. Instead of expecting a struct of type any, I have converted it to use a map[string]any. This largely works the same way, but with the benefit that defining variables is a bit nicer syntactically and we can utilise functions like maps.Copy() to do key merging. This allows us to define a predefined set of variables for use in all tests and then merge additional values if required.

Variables being made available for now are:

  • TEST_NAME - Contains the name of the test
  • TEST_DIR - Contains the absolute path to the test directory

I have removed PPRemoveAbsolutePaths in favor of this new technique.

One small hiccup is that since #2256 was merged, running task gen:fixtures will remove the template values from the golden files which then causes the tests to fail. This can be resolved manually, but is a bit of a pain. This is reported in sebdah/goldie#14 and I am considering an upstream feature request if @sebdah is interested. have opened a PR to address it.

@pd93 pd93 marked this pull request as draft May 20, 2025 21:38
@sebdah
Copy link

sebdah commented May 21, 2025

This is a good idea. I'd be happy to merge this into goldie if you'd want to submit a PR.

@pd93 pd93 force-pushed the update-tests-with-fixture-templates branch from 85d3754 to bc585d3 Compare July 9, 2025 10:14
@pd93 pd93 marked this pull request as ready for review July 9, 2025 10:14
@pd93
Copy link
Member Author

pd93 commented Jul 9, 2025

Goldie v2.7.1 has been released with both my PRs (sebdah/goldie#44, sebdah/goldie#45) merged. I've updated this PR and we should be good to merge now.

Thanks @sebdah for your help getting this done!

@pd93 pd93 merged commit 1c6d686 into main Jul 23, 2025
15 checks passed
@pd93 pd93 deleted the update-tests-with-fixture-templates branch July 23, 2025 20:57
pd93 added a commit that referenced this pull request Jul 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants