forked from mostafa/xk6-kafka
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserde_registry_test.go
29 lines (23 loc) · 1.11 KB
/
serde_registry_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package kafka
import (
"reflect"
"runtime"
"testing"
"github.com/stretchr/testify/assert"
)
// getFuncName returns the name of the function as string
func getFuncName(function interface{}) string {
return runtime.FuncForPC(reflect.ValueOf(function).Pointer()).Name()
}
// TestSerializersRegistry tests the serdes registry.
func TestSerdesRegistry(t *testing.T) {
serializersRegistry := NewSerializersRegistry()
deserializersRegistry := NewDeserializersRegistry()
assert.Equal(t, 5, len(serializersRegistry.Registry))
assert.Equal(t, String, serializersRegistry.Registry[StringSerializer].GetSchemaType())
assert.Equal(t, "github.com/mostafa/xk6-kafka.SerializeString", getFuncName(serializersRegistry.Registry[StringSerializer].GetSerializer()))
assert.False(t, serializersRegistry.Registry[StringSerializer].IsWireFormatted())
assert.Equal(t, 5, len(deserializersRegistry.Registry))
assert.Equal(t, "github.com/mostafa/xk6-kafka.DeserializeString", getFuncName(deserializersRegistry.Registry[StringDeserializer].GetDeserializer()))
assert.False(t, deserializersRegistry.Registry[StringDeserializer].IsWireFormatted())
}