@@ -71,15 +71,26 @@ func TestKafkaFactory(t *testing.T) {
7171 assert .Error (t , err )
7272}
7373
74- func TestKafkaFactoryProto (t * testing.T ) {
75- f := NewFactory ()
76- v , command := config .Viperize (f .AddFlags )
77- command .ParseFlags ([]string {"--kafka.encoding=protobuf" })
78- f .InitFromViper (v )
79-
80- f .config = & mockProducerBuilder {t : t }
81- assert .NoError (t , f .Initialize (metrics .NullFactory , zap .NewNop ()))
82- assert .IsType (t , & protobufMarshaller {}, f .marshaller )
74+ func TestKafkaFactoryEncoding (t * testing.T ) {
75+ tests := []struct {
76+ encoding string
77+ marshaller Marshaller
78+ }{
79+ {encoding : "protobuf" , marshaller : new (protobufMarshaller )},
80+ {encoding : "json" , marshaller : new (jsonMarshaller )},
81+ }
82+ for _ , test := range tests {
83+ t .Run (test .encoding , func (t * testing.T ) {
84+ f := NewFactory ()
85+ v , command := config .Viperize (f .AddFlags )
86+ command .ParseFlags ([]string {"--kafka.encoding=" + test .encoding })
87+ f .InitFromViper (v )
88+
89+ f .config = & mockProducerBuilder {t : t }
90+ assert .NoError (t , f .Initialize (metrics .NullFactory , zap .NewNop ()))
91+ assert .IsType (t , test .marshaller , f .marshaller )
92+ })
93+ }
8394}
8495
8596func TestKafkaFactoryMarshallerErr (t * testing.T ) {
0 commit comments