Skip to content

chore: replace PPRemoveAbsolutePaths with generic fixture template data #2265

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants