gotest.tools icon indicating copy to clipboard operation
gotest.tools copied to clipboard

How to compare multi-line strings with unpredictable values?

Open dnephin opened this issue 7 years ago • 2 comments

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).

dnephin avatar Aug 11 '17 20:08 dnephin

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.

dnephin avatar Sep 23 '17 16:09 dnephin

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.

dnephin avatar Nov 21 '17 18:11 dnephin