Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed missing TaskInfoStatus and TaskInfoType handling in ObjectExtensions #557

Merged
merged 2 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/Meilisearch/Extensions/ObjectExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ internal static string ToQueryString(this object source, BindingFlags bindingAtt
{
values.Add(key + "=" + string.Join(",", (List<int>)value));
}
else if (itemType == typeof(TaskInfoStatus))
{
values.Add(key + "=" + string.Join(",", ((List<TaskInfoStatus>)value).Select(x => x.ToString())));
}
else if (itemType == typeof(TaskInfoType))
{
values.Add(key + "=" + string.Join(",", ((List<TaskInfoType>)value).Select(x => x.ToString())));
}
}
else if (value is DateTime)
{
Expand Down
19 changes: 19 additions & 0 deletions tests/Meilisearch.Tests/ObjectExtensionsTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.Json.Serialization;

using Meilisearch.Converters;
using Meilisearch.Extensions;
using Meilisearch.QueryParameters;

Expand All @@ -17,6 +19,8 @@ public class FakeQuery
public string FakeString { get; set; }
public int? FakeInteger { get; set; }
public List<string> FakeStringList { get; set; }
public List<TaskInfoStatus> FakeStatusList { get; set; }
public List<TaskInfoType> FakeTypeList { get; set; }
public string Path { get; set; }
}

Expand All @@ -40,6 +44,21 @@ public static IEnumerable<object[]> FakeData()
new FakeQuery { FakeDate = date, FakeStringList = new List<string> { "hey", "ho" } },
$"fakeDate={Uri.EscapeDataString(date.ToString("yyyy-MM-dd'T'HH:mm:ss.fffzzz"))}&fakeStringList=hey,ho"
};

yield return new object[] {
new FakeQuery { FakeStatusList = new List<TaskInfoStatus> { TaskInfoStatus.Enqueued, TaskInfoStatus.Succeeded } },
"fakeStatusList=Enqueued,Succeeded"
};

yield return new object[] {
new FakeQuery { FakeTypeList = new List<TaskInfoType> { TaskInfoType.IndexCreation, TaskInfoType.DocumentDeletion } },
"fakeTypeList=IndexCreation,DocumentDeletion"
};

yield return new object[] {
new FakeQuery { FakeStatusList = new List<TaskInfoStatus> { TaskInfoStatus.Processing }, FakeTypeList = new List<TaskInfoType> { TaskInfoType.SettingsUpdate } },
"fakeStatusList=Processing&fakeTypeList=SettingsUpdate"
};
}

[Theory]
Expand Down
Loading