@@ -37,50 +37,50 @@ func TestHeaderWriter(t *testing.T) {
3737 name string
3838 initial * commonpb.Header
3939 expected * commonpb.Header
40- vals map [string ][] byte
40+ vals map [string ]* commonpb. Payload
4141 }{
4242 {
4343 "no values" ,
4444 & commonpb.Header {
45- Fields : map [string ][] byte {},
45+ Fields : map [string ]* commonpb. Payload {},
4646 },
4747 & commonpb.Header {
48- Fields : map [string ][] byte {},
48+ Fields : map [string ]* commonpb. Payload {},
4949 },
50- map [string ][] byte {},
50+ map [string ]* commonpb. Payload {},
5151 },
5252 {
5353 "add values" ,
5454 & commonpb.Header {
55- Fields : map [string ][] byte {},
55+ Fields : map [string ]* commonpb. Payload {},
5656 },
5757 & commonpb.Header {
58- Fields : map [string ][] byte {
59- "key1" : [] byte ( "val1" ),
60- "key2" : [] byte ( "val2" ),
58+ Fields : map [string ]* commonpb. Payload {
59+ "key1" : encodeString ( t , "val1" ),
60+ "key2" : encodeString ( t , "val2" ),
6161 },
6262 },
63- map [string ][] byte {
64- "key1" : [] byte ( "val1" ),
65- "key2" : [] byte ( "val2" ),
63+ map [string ]* commonpb. Payload {
64+ "key1" : encodeString ( t , "val1" ),
65+ "key2" : encodeString ( t , "val2" ),
6666 },
6767 },
6868 {
6969 "overwrite values" ,
7070 & commonpb.Header {
71- Fields : map [string ][] byte {
72- "key1" : [] byte ( "unexpected" ),
71+ Fields : map [string ]* commonpb. Payload {
72+ "key1" : encodeString ( t , "unexpected" ),
7373 },
7474 },
7575 & commonpb.Header {
76- Fields : map [string ][] byte {
77- "key1" : [] byte ( "val1" ),
78- "key2" : [] byte ( "val2" ),
76+ Fields : map [string ]* commonpb. Payload {
77+ "key1" : encodeString ( t , "val1" ),
78+ "key2" : encodeString ( t , "val2" ),
7979 },
8080 },
81- map [string ][] byte {
82- "key1" : [] byte ( "val1" ),
83- "key2" : [] byte ( "val2" ),
81+ map [string ]* commonpb. Payload {
82+ "key1" : encodeString ( t , "val1" ),
83+ "key2" : encodeString ( t , "val2" ),
8484 },
8585 },
8686 }
@@ -98,6 +98,12 @@ func TestHeaderWriter(t *testing.T) {
9898 }
9999}
100100
101+ func encodeString (t * testing.T , s string ) * commonpb.Payload {
102+ p , err := DefaultDataConverter .ToData (s )
103+ assert .NoError (t , err )
104+ return p
105+ }
106+
101107func TestHeaderReader (t * testing.T ) {
102108 t .Parallel ()
103109 tests := []struct {
@@ -109,9 +115,9 @@ func TestHeaderReader(t *testing.T) {
109115 {
110116 "valid values" ,
111117 & commonpb.Header {
112- Fields : map [string ][] byte {
113- "key1" : [] byte ( "val1" ),
114- "key2" : [] byte ( "val2" ),
118+ Fields : map [string ]* commonpb. Payload {
119+ "key1" : encodeString ( t , "val1" ),
120+ "key2" : encodeString ( t , "val2" ),
115121 },
116122 },
117123 map [string ]struct {}{"key1" : {}, "key2" : {}},
@@ -120,9 +126,9 @@ func TestHeaderReader(t *testing.T) {
120126 {
121127 "invalid values" ,
122128 & commonpb.Header {
123- Fields : map [string ][] byte {
124- "key1" : [] byte ( "val1" ),
125- "key2" : [] byte ( "val2" ),
129+ Fields : map [string ]* commonpb. Payload {
130+ "key1" : encodeString ( t , "val1" ),
131+ "key2" : encodeString ( t , "val2" ),
126132 },
127133 },
128134 map [string ]struct {}{"key2" : {}},
@@ -135,7 +141,7 @@ func TestHeaderReader(t *testing.T) {
135141 t .Run (test .name , func (t * testing.T ) {
136142 t .Parallel ()
137143 reader := NewHeaderReader (test .header )
138- err := reader .ForEachKey (func (key string , val [] byte ) error {
144+ err := reader .ForEachKey (func (key string , _ * commonpb. Payload ) error {
139145 if _ , ok := test .keys [key ]; ! ok {
140146 return assert .AnError
141147 }
0 commit comments