aboutsummaryrefslogtreecommitdiff
path: root/BackEnd/Timeline/Controllers
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
commit9494c9717f0d9983ec1c8db092387fef7199b00d (patch)
treecea8e25b7bded0833b3e4c6a5c1c018785cd3c30 /BackEnd/Timeline/Controllers
parent667f14149f32756a80018ead27102c63270644f4 (diff)
downloadtimeline-9494c9717f0d9983ec1c8db092387fef7199b00d.tar.gz
timeline-9494c9717f0d9983ec1c8db092387fef7199b00d.tar.bz2
timeline-9494c9717f0d9983ec1c8db092387fef7199b00d.zip
test: Add integrated tests for search api.
Diffstat (limited to 'BackEnd/Timeline/Controllers')
-rw-r--r--BackEnd/Timeline/Controllers/SearchController.cs14
-rw-r--r--BackEnd/Timeline/Controllers/TimelineController.cs2
2 files changed, 15 insertions, 1 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();