-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add example for using update option (#81)
and minor docs clean up
- Loading branch information
1 parent
ade9455
commit 875f35a
Showing
4 changed files
with
57 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
|
||
[TestUpdateWithFlag/test_-_0 - 1] | ||
lore ipsum dolor sit amet | ||
--- | ||
|
||
[TestUpdateWithFlag/test_-_1 - 1] | ||
consectetur adipiscing elit | ||
--- | ||
|
||
[TestUpdateWithFlag/test_-_2 - 1] | ||
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua | ||
--- | ||
|
||
[TestUpdateWithFlag/test_-_3 - 1] | ||
Ut enim ad minim veniam, quis nostrud laboris nisi ut aliquip ex ea commodo consequat. | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package examples | ||
|
||
import ( | ||
"flag" | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/gkampitakis/go-snaps/snaps" | ||
) | ||
|
||
// You can use -update flag to control if you want to update the snapshots | ||
// go test ./... -v -update | ||
var updateSnapshot = flag.Bool("update", false, "update snapshots flag") | ||
|
||
func TestUpdateWithFlag(t *testing.T) { | ||
snaps := snaps.WithConfig(snaps.Update(*updateSnapshot)) | ||
|
||
inputs := []string{ | ||
"lore ipsum dolor sit amet", | ||
"consectetur adipiscing elit", | ||
"sed do eiusmod tempor incididunt ut labore et dolore magna aliqua", | ||
"Ut enim ad minim veniam, quis nostrud laboris nisi ut aliquip ex ea commodo consequat.", | ||
} | ||
|
||
for i, input := range inputs { | ||
t.Run(fmt.Sprintf("test - %d", i), func(t *testing.T) { | ||
snaps.MatchSnapshot(t, input) | ||
}) | ||
} | ||
} |