Content-Length: 4166 | pFad | http://github.com/github/github-mcp-server/pull/97.patch
thub.com
From e041974387a7319d2dffff445bc0405fdf08dfab Mon Sep 17 00:00:00 2001
From: Javier Uruen Val
Date: Fri, 4 Apr 2025 12:48:08 +0200
Subject: [PATCH] assert query params
---
pkg/github/search_test.go | 68 +++++++++++++++++++++++++++++++--------
1 file changed, 54 insertions(+), 14 deletions(-)
diff --git a/pkg/github/search_test.go b/pkg/github/search_test.go
index 69fa7ca4e..44513b1f5 100644
--- a/pkg/github/search_test.go
+++ b/pkg/github/search_test.go
@@ -60,15 +60,21 @@ 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,
@@ -76,9 +82,15 @@ func Test_SearchRepositories(t *testing.T) {
{
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{}{
@@ -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{}{
@@ -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{}{
@@ -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{}{
@@ -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{}{
--- a PPN by Garber Painting Akron. With Image Size Reduction included!Fetched URL: http://github.com/github/github-mcp-server/pull/97.patch
Alternative Proxies:
Alternative Proxy
pFad Proxy
pFad v3 Proxy
pFad v4 Proxy