Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions sloggers/slogtest/assert/assert.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Package assert is a helper package for test assertions.
package assert
package assert // import "cdr.dev/slog/sloggers/slogtest/assert"

import (
"testing"
Expand All @@ -11,8 +11,8 @@ import (

// Equal asserts exp == act.
//
// If they are not equal, it will fatal the test
// with a diff of the differences.
// If they are not equal, it will fatal the test with a diff of the
// two objects.
func Equal(t testing.TB, exp, act interface{}, name string) {
slog.Helper()
if diff := assert.CmpDiff(exp, act); diff != "" {
Expand All @@ -24,6 +24,8 @@ func Equal(t testing.TB, exp, act interface{}, name string) {
}

// Success asserts err == nil.
//
// If err isn't nil, it will fatal the test with the error.
func Success(t testing.TB, err error, name string) {
slog.Helper()
if err != nil {
Expand All @@ -34,7 +36,9 @@ func Success(t testing.TB, err error, name string) {
}
}

// True act == true.
// True asserts act == true.
//
// If act isn't true, it will fatal the test.
func True(t testing.TB, act bool, name string) {
slog.Helper()
Equal(t, true, act, name)
Expand Down