aboutsummaryrefslogtreecommitdiff
path: root/BackEnd/Timeline
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2021-01-19 15:24:39 +0800
committercrupest <crupest@outlook.com>2021-01-19 15:24:39 +0800
commitfb6442f1716406c7a2da79e4a1cc42e23908d218 (patch)
tree455fbd07678b1b21a1bfa3ad7e3778b1957fd12f /BackEnd/Timeline
parent208ae3f6371857e2b06cf789a640989f64f80a24 (diff)
downloadtimeline-fb6442f1716406c7a2da79e4a1cc42e23908d218.tar.gz
timeline-fb6442f1716406c7a2da79e4a1cc42e23908d218.tar.bz2
timeline-fb6442f1716406c7a2da79e4a1cc42e23908d218.zip
test: Add integrated tests for search api.
Diffstat (limited to 'BackEnd/Timeline')
-rw-r--r--BackEnd/Timeline/Controllers/SearchController.cs14
-rw-r--r--BackEnd/Timeline/Controllers/TimelineController.cs2
-rw-r--r--BackEnd/Timeline/Models/Http/TimelineController.cs2
3 files changed, 16 insertions, 2 deletions
diff --git a/BackEnd/Timeline/Controllers/SearchController.cs b/BackEnd/Timeline/Controllers/SearchController.cs
index 915938de..dec876b6 100644
--- a/BackEnd/Timeline/Controllers/SearchController.cs
+++ b/BackEnd/Timeline/Controllers/SearchController.cs
@@ -28,7 +28,14 @@ namespace Timeline.Controllers
_userMapper = userMapper;
}
+ /// <summary>
+ /// Search timelines whose name or title contains query string case-insensitively.
+ /// </summary>
+ /// <param name="query">The string to contain.</param>
+ /// <returns>Timelines with most related at first.</returns>
[HttpGet("timelines")]
+ [ProducesResponseType(200)]
+ [ProducesResponseType(400)]
public async Task<ActionResult<List<HttpTimeline>>> TimelineSearch([FromQuery(Name = "q"), Required(AllowEmptyStrings = false)] string query)
{
var searchResult = await _service.SearchTimeline(query);
@@ -36,7 +43,14 @@ namespace Timeline.Controllers
return await _timelineMapper.MapToHttp(timelines, Url, this.GetOptionalUserId());
}
+ /// <summary>
+ /// Search users whose username or nick contains query string case-insensitively.
+ /// </summary>
+ /// <param name="query">The string to contain.</param>
+ /// <returns>Users with most related at first.</returns>
[HttpGet("users")]
+ [ProducesResponseType(200)]
+ [ProducesResponseType(400)]
public async Task<ActionResult<List<HttpUser>>> UserSearch([FromQuery(Name = "q"), Required(AllowEmptyStrings = false)] string query)
{
var searchResult = await _service.SearchUser(query);
diff --git a/BackEnd/Timeline/Controllers/TimelineController.cs b/BackEnd/Timeline/Controllers/TimelineController.cs
index b2e37b15..5d484388 100644
--- a/BackEnd/Timeline/Controllers/TimelineController.cs
+++ b/BackEnd/Timeline/Controllers/TimelineController.cs
@@ -441,7 +441,7 @@ namespace Timeline.Controllers
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
- public async Task<ActionResult<HttpTimeline>> TimelineCreate([FromBody] TimelineCreateRequest body)
+ public async Task<ActionResult<HttpTimeline>> TimelineCreate([FromBody] HttpTimelineCreateRequest body)
{
var userId = this.GetUserId();
diff --git a/BackEnd/Timeline/Models/Http/TimelineController.cs b/BackEnd/Timeline/Models/Http/TimelineController.cs
index f6039b35..257076f0 100644
--- a/BackEnd/Timeline/Models/Http/TimelineController.cs
+++ b/BackEnd/Timeline/Models/Http/TimelineController.cs
@@ -43,7 +43,7 @@ namespace Timeline.Models.Http
/// <summary>
/// Create timeline request model.
/// </summary>
- public class TimelineCreateRequest
+ public class HttpTimelineCreateRequest
{
/// <summary>
/// Name of the new timeline. Must be a valid name.