Skip to content

Commit

Permalink
fail test when new snapshot identified, closes #26
Browse files Browse the repository at this point in the history
  • Loading branch information
sjkaliski committed Oct 21, 2017
1 parent a061fc7 commit 4273dd0
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions assert.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ func createOrUpdateSnapshot(t *testing.T, id, data string) {

var err error
if snapshot == nil {
if !args.shouldUpdate {
t.Error(newSnapshotMessage(data))
return
}

fmt.Printf("Creating snapshot `%s`\n", id)
snapshot, err = createSnapshot(snapshotID(id), data)
if err != nil {
Expand All @@ -103,9 +108,7 @@ func createOrUpdateSnapshot(t *testing.T, id, data string) {
return
}

msg := didNotMatchMessage(diff)

t.Error(msg)
t.Error(didNotMatchMessage(diff))
return
}
}
Expand Down Expand Up @@ -135,3 +138,11 @@ func didNotMatchMessage(diff string) string {
msg += "If this change was intentional, run tests again, $ go test -v -- -u\n"
return msg
}

func newSnapshotMessage(body string) string {
msg := "\n\nNew snapshot found...\n\n"
msg += body
msg += "\n\n"
msg += "To save, run tests again, $ go test -v -- -u\n"
return msg
}

0 comments on commit 4273dd0

Please sign in to comment.