gkampitakis / go-snaps

Jest-like snapshot testing in Go 📸
https://pkg.go.dev/github.com/gkampitakis/go-snaps
MIT License
158 stars 6 forks source link

Testcase is intially written, but fails on updating the test #30

Closed markussiebert closed 2 years ago

markussiebert commented 2 years ago

Hi,

if I create the test case, everything is fine... if I update it, it is updated in a wrong way so that from this point on all tests will fail. It only is possible to fix if I delete the snaps and create them from scratch...

--- FAIL: Test_UpdateSecret (0.00s)
    mocks.go:24: 
         Snapshot 
         Received 

        >>>SecretsManagerMockClient.PutSecretValue.Input
        {
          ClientRequestToken: "4547532a137611d83958d17095c6c2d38ae0036a760c3b79c9dd5957d1c20cf2.yaml",
          SecretId: "arn:${Partition}:secretsmanager:::secret:${Region}:${Account}:secret:${SecretId}",
          SecretString: <sensitive>
        }
image

Do you need more information?

gkampitakis commented 2 years ago

Hello :wave: , could you give me some more information and/or a way to reproduce it ? This looks weird and can't think of a reason on top of my head why this might be happening

gkampitakis commented 2 years ago

Okay had a look at your snapshot. The issue is the special ${} chars and a method in a regex I use that I was not aware of.

I should be using ReplaceAllLiteralString instead of ReplaceAllString.

I believe you have found all the edge cases, sorry and thank you for that, I use this library but not so heavily so I haven't found all those issues :sweat:

Going to create a pr and release a "fix" version for this.

gkampitakis commented 2 years ago

Going to release now a new version with the fix, if the issue persists feel free to reopen it