(t *testing.T)
| 3504 | } |
| 3505 | |
| 3506 | func Test_ListReleases(t *testing.T) { |
| 3507 | serverTool := ListReleases(translations.NullTranslationHelper) |
| 3508 | tool := serverTool.Tool |
| 3509 | require.NoError(t, toolsnaps.Test(tool.Name, tool)) |
| 3510 | |
| 3511 | schema, ok := tool.InputSchema.(*jsonschema.Schema) |
| 3512 | require.True(t, ok, "InputSchema should be *jsonschema.Schema") |
| 3513 | |
| 3514 | assert.Equal(t, "list_releases", tool.Name) |
| 3515 | assert.NotEmpty(t, tool.Description) |
| 3516 | assert.Contains(t, schema.Properties, "owner") |
| 3517 | assert.Contains(t, schema.Properties, "repo") |
| 3518 | assert.ElementsMatch(t, schema.Required, []string{"owner", "repo"}) |
| 3519 | |
| 3520 | mockReleases := []*github.RepositoryRelease{ |
| 3521 | { |
| 3522 | ID: github.Ptr(int64(1)), |
| 3523 | TagName: github.Ptr("v1.0.0"), |
| 3524 | Name: github.Ptr("First Release"), |
| 3525 | }, |
| 3526 | { |
| 3527 | ID: github.Ptr(int64(2)), |
| 3528 | TagName: github.Ptr("v0.9.0"), |
| 3529 | Name: github.Ptr("Beta Release"), |
| 3530 | }, |
| 3531 | } |
| 3532 | |
| 3533 | tests := []struct { |
| 3534 | name string |
| 3535 | mockedClient *http.Client |
| 3536 | requestArgs map[string]any |
| 3537 | expectError bool |
| 3538 | expectedResult []*github.RepositoryRelease |
| 3539 | expectedErrMsg string |
| 3540 | }{ |
| 3541 | { |
| 3542 | name: "successful releases list", |
| 3543 | mockedClient: NewMockedHTTPClient( |
| 3544 | WithRequestMatch( |
| 3545 | GetReposReleasesByOwnerByRepo, |
| 3546 | mockReleases, |
| 3547 | ), |
| 3548 | ), |
| 3549 | requestArgs: map[string]any{ |
| 3550 | "owner": "owner", |
| 3551 | "repo": "repo", |
| 3552 | }, |
| 3553 | expectError: false, |
| 3554 | expectedResult: mockReleases, |
| 3555 | }, |
| 3556 | { |
| 3557 | name: "releases list fails", |
| 3558 | mockedClient: NewMockedHTTPClient( |
| 3559 | WithRequestMatchHandler( |
| 3560 | GetReposReleasesByOwnerByRepo, |
| 3561 | http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { |
| 3562 | w.WriteHeader(http.StatusNotFound) |
| 3563 | _, _ = w.Write([]byte(`{"message": "Not Found"}`)) |
nothing calls this directly
no test coverage detected