mirror of https://github.com/dapr/go-sdk.git
Signed-off-by: Paul Thiele <thielepaul@gmail.com>
This commit is contained in:
parent
4298f3fa7d
commit
49deb758ee
|
|
@ -37,6 +37,7 @@ func (m TopicRegistrar) AddSubscription(sub *common.Subscription, fn common.Topi
|
|||
RouteHandlers: make(map[string]common.TopicEventHandler),
|
||||
DefaultHandler: nil,
|
||||
}
|
||||
ts.Subscription.SetMetadata(sub.Metadata)
|
||||
m[key] = ts
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -71,3 +71,25 @@ func TestTopicRegistrarValidation(t *testing.T) {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestTopicAddSubscriptionMetadata(t *testing.T) {
|
||||
handler := func(ctx context.Context, e *common.TopicEvent) (retry bool, err error) {
|
||||
return false, nil
|
||||
}
|
||||
topicRegistrar := internal.TopicRegistrar{}
|
||||
sub := &common.Subscription{
|
||||
PubsubName: "pubsubname",
|
||||
Topic: "topic",
|
||||
Metadata: map[string]string{"key": "value"},
|
||||
}
|
||||
|
||||
assert.NoError(t, topicRegistrar.AddSubscription(sub, handler))
|
||||
|
||||
actual := topicRegistrar["pubsubname-topic"].Subscription
|
||||
expected := &internal.TopicSubscription{
|
||||
PubsubName: sub.PubsubName,
|
||||
Topic: sub.Topic,
|
||||
Metadata: sub.Metadata,
|
||||
}
|
||||
assert.Equal(t, expected, actual)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue