topicmetadata should allow adding empty strings (#940)

* topicmetadata should allow adding empty strings
Signed-off-by: saberwang <saberwang@hotmail.com>

* fix test errors
Signed-off-by: saberwang <saberwang@hotmail.com>
This commit is contained in:
saber-wang 2022-08-30 02:42:17 +08:00 committed by GitHub
parent 2ab1b7cee0
commit 0998b0dd4d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 4 deletions

View File

@ -29,7 +29,7 @@ namespace Dapr
public TopicMetadataAttribute(string name, string value)
{
ArgumentVerifier.ThrowIfNullOrEmpty(name, nameof(name));
ArgumentVerifier.ThrowIfNullOrEmpty(value, nameof(value));
ArgumentVerifier.ThrowIfNull(value, nameof(value));
Name = name;
Value = value;
}
@ -44,7 +44,7 @@ namespace Dapr
{
ArgumentVerifier.ThrowIfNullOrEmpty(id, nameof(name));
ArgumentVerifier.ThrowIfNullOrEmpty(name, nameof(name));
ArgumentVerifier.ThrowIfNullOrEmpty(value, nameof(value));
ArgumentVerifier.ThrowIfNull(value, nameof(value));
Id = id;
Name = name;
Value = value;

View File

@ -92,6 +92,14 @@ namespace Dapr.AspNetCore.IntegrationTest.App
{
}
[Topic("pubsub", "metadataseparatorbyemptytring")]
[HttpPost("/topicmetadataseparatorattrbyemptytring")]
[TopicMetadata("n1", "v1")]
[TopicMetadata("n1", "")]
public void TopicMetadataSeparatorByemptytring ()
{
}
[Topic("pubsub", "splitTopicAttr", true)]
[HttpPost("/splitTopics")]
public void SplitTopic()

View File

@ -39,7 +39,7 @@ namespace Dapr.AspNetCore.IntegrationTest
var json = await JsonSerializer.DeserializeAsync<JsonElement>(stream);
json.ValueKind.Should().Be(JsonValueKind.Array);
json.GetArrayLength().Should().Be(17);
json.GetArrayLength().Should().Be(18);
var subscriptions = new List<(string PubsubName, string Topic, string Route, string rawPayload, string match, string metadata, string DeadLetterTopic)>();
@ -116,7 +116,7 @@ namespace Dapr.AspNetCore.IntegrationTest
subscriptions.Should().Contain(("pubsub", "metadata", "multiMetadataTopicAttr", string.Empty, string.Empty, "n1=v1;n2=v2,v3", string.Empty));
subscriptions.Should().Contain(("pubsub", "metadata.1", "multiMetadataTopicAttr", "true", string.Empty, "n1=v1", string.Empty));
subscriptions.Should().Contain(("pubsub", "splitMetadataTopicBuilder", "splitMetadataTopics", string.Empty, string.Empty, "n1=v1;n2=v1", string.Empty));
subscriptions.Should().Contain(("pubsub", "metadataseparatorbyemptytring", "topicmetadataseparatorattrbyemptytring", string.Empty, string.Empty, "n1=v1,", string.Empty));
// Test priority route sorting
var eTopic = subscriptions.FindAll(e => e.Topic == "E");
eTopic.Count.Should().Be(3);