+16
-14
lines changedFilter options
+16
-14
lines changed Original file line number Diff line number Diff line change
@@ -35,15 +35,11 @@ func TestSendEvent(t *testing.T) {
35
35
clienttest.SendReceive(t, func() interface{} {
36
36
return protocolFactory(t)
37
37
}, eventIn, func(eventOut event.Event) {
38
-
eventOut = test.ConvertEventExtensionsToString(t, eventOut)
39
-
40
-
require.Equal(t, TopicName, eventOut.Extensions()[KAFKA_TOPIC])
41
-
require.NotNil(t, eventOut.Extensions()[KAFKA_PARTITION])
42
-
require.NotNil(t, eventOut.Extensions()[KAFKA_OFFSET])
43
-
44
38
test.AllOf(
45
39
test.HasExactlyAttributesEqualTo(eventIn.Context),
46
40
test.HasData(eventIn.Data()),
41
+
test.HasExtensionKeys([]string{KAFKA_OFFSET, KAFKA_PARTITION}),
42
+
test.HasExtension(KAFKA_TOPIC, TopicName),
47
43
)
48
44
})
49
45
})
Original file line number Diff line number Diff line change
@@ -56,17 +56,12 @@ func TestSendBinaryMessageToBinary(t *testing.T) {
56
56
57
57
in := MustCreateMockBinaryMessage(eventIn)
58
58
test.SendReceive(t, binding.WithPreferredEventEncoding(context.TODO(), binding.EncodingBinary), in, s, r, func(out binding.Message) {
59
-
eventOut := MustToEvent(t, context.Background(), out)
60
59
assert.Equal(t, binding.EncodingBinary, out.ReadEncoding())
61
-
eventOut = ConvertEventExtensionsToString(t, eventOut)
62
-
63
-
require.Equal(t, topicName, eventOut.Extensions()[KAFKA_TOPIC])
64
-
require.NotNil(t, eventOut.Extensions()[KAFKA_PARTITION])
65
-
require.NotNil(t, eventOut.Extensions()[KAFKA_OFFSET])
66
-
67
60
AllOf(
68
61
HasExactlyAttributesEqualTo(eventIn.Context),
69
62
HasData(eventIn.Data()),
63
+
HasExtensionKeys([]string{KAFKA_OFFSET, KAFKA_PARTITION}),
64
+
HasExtension(KAFKA_TOPIC, topicName),
70
65
)
71
66
})
72
67
})
Original file line number Diff line number Diff line change
@@ -184,6 +184,18 @@ func HasExtensions(ext map[string]interface{}) EventMatcher {
184
184
}
185
185
}
186
186
187
+
// HasExtensionKeys checks if the event contains the provided keys from its extensions
188
+
func HasExtensionKeys(keys []string) EventMatcher {
189
+
return func(have event.Event) error {
190
+
for _, k := range keys {
191
+
if _, ok := have.Extensions()[k]; !ok {
192
+
return fmt.Errorf("expecting extension key %q", k)
193
+
}
194
+
}
195
+
return nil
196
+
}
197
+
}
198
+
187
199
// HasExtension checks if the event contains the provided extension
188
200
func HasExtension(key string, value interface{}) EventMatcher {
189
201
return HasExtensions(map[string]interface{}{key: value})
@@ -277,7 +289,6 @@ func HasAttributeKind(kind spec.Kind, value interface{}) EventMatcher {
277
289
// LICENSE: MIT License
278
290
279
291
func isEmpty(object interface{}) bool {
280
-
281
292
// get nil case out of the way
282
293
if object == nil {
283
294
return true
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4