Migrate from testify to nalgeon/be testing library

- Replace all testify/assert and testify/require with be library
- Update go.mod to use be v0.3.0 instead of testify
- Simplify test assertions using be.Equal, be.Err, and be.True
- Refactor append_test, entry_test, meta_test, log_test, and formatter tests
This commit is contained in:
Dan Jones 2026-02-13 14:12:30 -06:00
commit 1110288d84
16 changed files with 226 additions and 236 deletions

View file

@ -5,8 +5,7 @@ import (
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/nalgeon/be"
)
const day = time.Hour * 24
@ -58,11 +57,10 @@ func getDateTest(in string, exp time.Time, err string) func(t *testing.T) {
return func(t *testing.T) {
out, er := ParseDate(in)
if err != "" {
assert.ErrorContains(t, er, err)
be.Err(t, er, err)
} else {
require.NoError(t, er)
assert.Equal(t, exp, out)
be.Err(t, er, nil)
be.Equal(t, out, exp)
}
}
}

View file

@ -5,7 +5,7 @@ import (
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/nalgeon/be"
)
func TestParse(t *testing.T) {
@ -54,20 +54,18 @@ func getParseTestRunner(in string, exp any) func(*testing.T) {
out := ParseString(in)
if expT, ok := exp.(time.Time); ok {
ti, gotTime := out.(time.Time)
if assert.True(t, gotTime, "Should have gotten a time.Time, but didn't") {
assert.WithinRange(t, expT, ti.Add(-2*time.Second), ti.Add(2*time.Second))
}
be.True(t, gotTime)
be.True(t, expT.After(ti.Add(-2*time.Second)) && expT.Before(ti.Add(2*time.Second)))
} else {
assert.Equal(t, exp, out)
be.Equal(t, out, exp)
}
out = ParseBytes([]byte(in))
if expT, ok := exp.(time.Time); ok {
ti, gotTime := out.(time.Time)
if assert.True(t, gotTime, "Should have gotten a time.Time, but didn't") {
assert.WithinRange(t, expT, ti.Add(-2*time.Second), ti.Add(2*time.Second))
}
be.True(t, gotTime)
be.True(t, expT.After(ti.Add(-2*time.Second)) && expT.Before(ti.Add(2*time.Second)))
} else {
assert.Equal(t, exp, out)
be.Equal(t, out, exp)
}
}
}

View file

@ -7,7 +7,7 @@ import (
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/nalgeon/be"
)
func TestWriteBuffer(t *testing.T) {
@ -52,8 +52,8 @@ func getWriteTestRunner(value any, out string, err error) func(*testing.T) {
return func(t *testing.T) {
buff := &bytes.Buffer{}
n, er := WriteValue(buff, value)
assert.Equal(t, len(out), n)
assert.Equal(t, err, er)
assert.Equal(t, out, buff.String())
be.Equal(t, n, len(out))
be.Equal(t, er, err)
be.Equal(t, buff.String(), out)
}
}