✨ Add bep.JSON helper for JSON assertion in tests
- Create internal/testutil/bep package with JSON helper - Use bep.JSON in formatters/json_test.go, models/entry_test.go, and models/meta_test.go
This commit is contained in:
parent
1110288d84
commit
ebb0b12069
4 changed files with 29 additions and 21 deletions
21
internal/testutil/bep/json.go
Normal file
21
internal/testutil/bep/json.go
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
package bep
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"testing"
|
||||
|
||||
"github.com/nalgeon/be"
|
||||
)
|
||||
|
||||
func JSON(t *testing.T, got, want []byte) {
|
||||
t.Helper()
|
||||
|
||||
var gotAny, wantAny any
|
||||
err := json.Unmarshal(want, &wantAny)
|
||||
be.Err(t, err, nil)
|
||||
|
||||
err = json.Unmarshal(got, &gotAny)
|
||||
be.Err(t, err, nil)
|
||||
|
||||
be.Equal(t, gotAny, wantAny)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue