From 9494c9717f0d9983ec1c8db092387fef7199b00d Mon Sep 17 00:00:00 2001 From: crupest Date: Tue, 19 Jan 2021 15:24:39 +0800 Subject: test: Add integrated tests for search api. --- BackEnd/Timeline/Controllers/SearchController.cs | 14 ++++++++++++++ BackEnd/Timeline/Controllers/TimelineController.cs | 2 +- BackEnd/Timeline/Models/Http/TimelineController.cs | 2 +- 3 files changed, 16 insertions(+), 2 deletions(-) (limited to 'BackEnd/Timeline') 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; } + /// + /// Search timelines whose name or title contains query string case-insensitively. + /// + /// The string to contain. + /// Timelines with most related at first. [HttpGet("timelines")] + [ProducesResponseType(200)] + [ProducesResponseType(400)] public async Task>> 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()); } + /// + /// Search users whose username or nick contains query string case-insensitively. + /// + /// The string to contain. + /// Users with most related at first. [HttpGet("users")] + [ProducesResponseType(200)] + [ProducesResponseType(400)] public async Task>> 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> TimelineCreate([FromBody] TimelineCreateRequest body) + public async Task> 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 /// /// Create timeline request model. /// - public class TimelineCreateRequest + public class HttpTimelineCreateRequest { /// /// Name of the new timeline. Must be a valid name. -- cgit v1.2.3