Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

assert query params in search_test#97

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
juruen merged 4 commits intomainfromjuruen/search_test
Apr 4, 2025
Merged
Changes fromall 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
68 changes: 54 additions & 14 deletionspkg/github/search_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -60,25 +60,37 @@ func Test_SearchRepositories(t *testing.T) {
{
name: "successful repository search",
mockedClient: mock.NewMockedHTTPClient(
mock.WithRequestMatch(
mock.WithRequestMatchHandler(
mock.GetSearchRepositories,
mockSearchResult,
expectQueryParams(t, map[string]string{
"q": "golang test",
"page": "2",
"per_page": "10",
}).andThen(
mockResponse(t, http.StatusOK, mockSearchResult),
),
),
),
requestArgs: map[string]interface{}{
"query": "golang test",
"page": float64(1),
"per_page": float64(30),
"page": float64(2),
"per_page": float64(10),
},
expectError: false,
expectedResult: mockSearchResult,
},
{
name: "repository search with default pagination",
mockedClient: mock.NewMockedHTTPClient(
mock.WithRequestMatch(
mock.WithRequestMatchHandler(
mock.GetSearchRepositories,
mockSearchResult,
expectQueryParams(t, map[string]string{
"q": "golang test",
"page": "1",
"per_page": "30",
}).andThen(
mockResponse(t, http.StatusOK, mockSearchResult),
),
),
),
requestArgs: map[string]interface{}{
Expand DownExpand Up@@ -195,9 +207,17 @@ func Test_SearchCode(t *testing.T) {
{
name: "successful code search with all parameters",
mockedClient: mock.NewMockedHTTPClient(
mock.WithRequestMatch(
mock.WithRequestMatchHandler(
mock.GetSearchCode,
mockSearchResult,
expectQueryParams(t, map[string]string{
"q": "fmt.Println language:go",
"sort": "indexed",
"order": "desc",
"page": "1",
"per_page": "30",
}).andThen(
mockResponse(t, http.StatusOK, mockSearchResult),
),
),
),
requestArgs: map[string]interface{}{
Expand All@@ -213,9 +233,15 @@ func Test_SearchCode(t *testing.T) {
{
name: "code search with minimal parameters",
mockedClient: mock.NewMockedHTTPClient(
mock.WithRequestMatch(
mock.WithRequestMatchHandler(
mock.GetSearchCode,
mockSearchResult,
expectQueryParams(t, map[string]string{
"q": "fmt.Println language:go",
"page": "1",
"per_page": "30",
}).andThen(
mockResponse(t, http.StatusOK, mockSearchResult),
),
),
),
requestArgs: map[string]interface{}{
Expand DownExpand Up@@ -336,9 +362,17 @@ func Test_SearchUsers(t *testing.T) {
{
name: "successful users search with all parameters",
mockedClient: mock.NewMockedHTTPClient(
mock.WithRequestMatch(
mock.WithRequestMatchHandler(
mock.GetSearchUsers,
mockSearchResult,
expectQueryParams(t, map[string]string{
"q": "location:finland language:go",
"sort": "followers",
"order": "desc",
"page": "1",
"per_page": "30",
}).andThen(
mockResponse(t, http.StatusOK, mockSearchResult),
),
),
),
requestArgs: map[string]interface{}{
Expand All@@ -354,9 +388,15 @@ func Test_SearchUsers(t *testing.T) {
{
name: "users search with minimal parameters",
mockedClient: mock.NewMockedHTTPClient(
mock.WithRequestMatch(
mock.WithRequestMatchHandler(
mock.GetSearchUsers,
mockSearchResult,
expectQueryParams(t, map[string]string{
"q": "location:finland language:go",
"page": "1",
"per_page": "30",
}).andThen(
mockResponse(t, http.StatusOK, mockSearchResult),
),
),
),
requestArgs: map[string]interface{}{
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp