Move codec test helper to an internal package

This commit is contained in:
Bjørn Erik Pedersen
2016-04-16 19:48:28 +02:00
parent 326601f21e
commit 54f1b599fe
5 changed files with 13 additions and 11 deletions

View File

@@ -1,3 +1,5 @@
// Package codec contains sub-packages with different codecs that can be used
// to encode and decode entities in Storm.
package codec
// EncodeDecoder represents a codec used to encode and decode entities.

View File

@@ -3,9 +3,9 @@ package json
import (
"testing"
"github.com/asdine/storm/codec"
"github.com/asdine/storm/codec/internal"
)
func TestGob(t *testing.T) {
codec.RountripTester(t, Codec)
internal.RoundtripTester(t, Codec)
}

View File

@@ -1,19 +1,19 @@
// Package codec contains sub-packages with different codecs that can be used
// to encode and decode entities in Storm.
package codec
package internal
import (
"encoding/gob"
"reflect"
"testing"
"github.com/asdine/storm/codec"
)
type testStruct struct {
Name string
}
// RountripTester is a test helper to test a EncodeDecoder
func RountripTester(t *testing.T, c EncodeDecoder, vals ...interface{}) {
// RoundtripTester is a test helper to test a EncodeDecoder
func RoundtripTester(t *testing.T, c codec.EncodeDecoder, vals ...interface{}) {
var val, to interface{}
if len(vals) > 0 {
if len(vals) != 2 {

View File

@@ -3,9 +3,9 @@ package json
import (
"testing"
"github.com/asdine/storm/codec"
"github.com/asdine/storm/codec/internal"
)
func TestJSON(t *testing.T) {
codec.RountripTester(t, Codec)
internal.RoundtripTester(t, Codec)
}

View File

@@ -3,7 +3,7 @@ package sereal
import (
"testing"
"github.com/asdine/storm/codec"
"github.com/asdine/storm/codec/internal"
"github.com/stretchr/testify/assert"
)
@@ -16,6 +16,6 @@ func TestSereal(t *testing.T) {
u1 := &SerealUser{Name: "Sereal"}
u1.Self = u1 // cyclic ref
u2 := &SerealUser{}
codec.RountripTester(t, Codec, &u1, &u2)
internal.RoundtripTester(t, Codec, &u1, &u2)
assert.True(t, u2 == u2.Self)
}