Skip to content

Commit

Permalink
rename
Browse files Browse the repository at this point in the history
  • Loading branch information
gkampitakis committed Nov 4, 2023
1 parent 8079926 commit 07b9880
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
39 changes: 38 additions & 1 deletion snaps/matchInline.go → snaps/matchInlineSnapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,49 @@ import (

type InlineSnapshot *string

// Inline representation of snapshot
func Inline(s string) InlineSnapshot {
return &s
}

/*
MatchInlineSnapshot verifies the value matches the inline snapshot
First you call it with nil
MatchInlineSnapshot(t, "mysnapshot", nil)
and it populates with the snapshot
MatchInlineSnapshot(t, "mysnapshot", snaps.Inline("mysnapshot"))
the on every subsequent call it verifies the value matches the snapshot
*/
func (c *config) MatchInlineSnapshot(t testingT, received interface{}, inlineSnap InlineSnapshot) {
t.Helper()

matchInlineSnapshot(c, t, received, inlineSnap)
}

/*
MatchInlineSnapshot verifies the value matches the inline snapshot
First you call it with nil
MatchInlineSnapshot(t, "mysnapshot", nil)
and it populates with the snapshot
MatchInlineSnapshot(t, "mysnapshot", snaps.Inline("mysnapshot"))
the on every subsequent call it verifies the value matches the snapshot
*/
func MatchInlineSnapshot(t testingT, received interface{}, inlineSnap InlineSnapshot) {
t.Helper()

matchInlineSnapshot(&defaultConfig, t, received, inlineSnap)
}

func matchInlineSnapshot(c *config, t testingT, received interface{}, inlineSnap InlineSnapshot) {
t.Helper()
snapshot := pretty.Sprint(received)
filename, line := baseCaller(1)

Expand All @@ -42,7 +79,7 @@ func MatchInlineSnapshot(t testingT, received interface{}, inlineSnap InlineSnap
return
}

if !shouldUpdateSingle(t.Name()) {
if !shouldUpdate(c.update) {
handleError(t, diff)
return
}
Expand Down
7 changes: 7 additions & 0 deletions snaps/matchInlineSnapshot_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package snaps

import "testing"

func TestMatchInlineSnapshot(t *testing.T) {
t.Error("unimplemented")
}

0 comments on commit 07b9880

Please sign in to comment.