Simple, intuitive snapshot testing for Go 📸
0

Configure Feed

Select the types of activity you want to include in your feed.

Ensure clean removes the entire snapshot directory (#31)

## Summary

<!-- Describe your changes in detail here, if it closes an open issue,
include "Closes #<issue>" -->

authored by

Tom Fleet and committed by
GitHub
(Mar 26, 2025, 9:02 AM UTC) bf8b2c4c 5f0148a0

+5 -7
+5 -7
snapshot.go
··· 75 75 // and use that in the call to MkDirAll 76 76 dir := filepath.Dir(path) 77 77 78 - // If clean is set, erase the snapshot directory and then carry on 78 + // If clean is set, erase the entire snapshot directory then carry on, 79 + // re-populating it with the fresh snaps 79 80 if s.clean { 80 - if err := os.RemoveAll(dir); err != nil { 81 - s.tb.Fatalf("failed to delete %s: %v", dir, err) 82 - 81 + toRemove := filepath.Join("testdata", "snapshots") 82 + if err := os.RemoveAll(toRemove); err != nil { 83 + s.tb.Fatalf("failed to delete %s: %v", toRemove, err) 83 84 return 84 85 } 85 86 } ··· 91 92 content, err := val.Snap() 92 93 if err != nil { 93 94 s.tb.Fatalf("%T implements Snapper but Snap() returned an error: %v", val, err) 94 - 95 95 return 96 96 } 97 97 ··· 101 101 content, err := json.MarshalIndent(val, "", " ") 102 102 if err != nil { 103 103 s.tb.Fatalf("%T implements json.Marshaler but MarshalJSON() returned an error: %v", val, err) 104 - 105 104 return 106 105 } 107 106 ··· 110 109 content, err := val.MarshalText() 111 110 if err != nil { 112 111 s.tb.Fatalf("%T implements encoding.TextMarshaler but MarshalText() returned an error: %v", val, err) 113 - 114 112 return 115 113 } 116 114