gotest.tools
gotest.tools copied to clipboard
How to compare multi-line strings with unpredictable values?
Ex: The stdout of docker build
includes ids that will change.
golden
expects exact values, but maybe we could support some way of templating things so that it can assert the actual result matches a template/pattern. This could be in a different package, or just a different assertions (AssertPattern()
or something).
I looked around for a library that could be used to parse this type of thing but I couldn't find anything that didn't just use regular expressions.
I went with this: https://github.com/docker/cli/pull/709/files, using a map of line -> check function
. It seems to work well for this case.