mirror of
https://github.com/chaisql/chai.git
synced 2025-10-06 16:18:14 +08:00
Write a basic test suite
This commit is contained in:
19
document/encoding/encodingtest/testing.go
Normal file
19
document/encoding/encodingtest/testing.go
Normal file
@@ -0,0 +1,19 @@
|
||||
// Package encodingtest provides a test suite for testing codec implementations.
|
||||
package encodingtest
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/genjidb/genji/document"
|
||||
"github.com/genjidb/genji/document/encoding"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
// TestCodec runs a list of tests on the given codec.
|
||||
func TestCodec(t *testing.T, codecBuilder func() encoding.Codec) {
|
||||
t.Run("Encoding using a nil reader should fail", func(t *testing.T) {
|
||||
codec := codecBuilder()
|
||||
err := codec.NewEncoder(nil).EncodeDocument(document.NewFieldBuffer().Add("a", document.NewBoolValue(true)))
|
||||
require.Error(t, err)
|
||||
})
|
||||
}
|
Reference in New Issue
Block a user