(t *testing.T)
| 4639 | } |
| 4640 | |
| 4641 | func Test_UnstarRepository(t *testing.T) { |
| 4642 | // Verify tool definition once |
| 4643 | serverTool := UnstarRepository(translations.NullTranslationHelper) |
| 4644 | tool := serverTool.Tool |
| 4645 | require.NoError(t, toolsnaps.Test(tool.Name, tool)) |
| 4646 | |
| 4647 | schema, ok := tool.InputSchema.(*jsonschema.Schema) |
| 4648 | require.True(t, ok, "InputSchema should be *jsonschema.Schema") |
| 4649 | |
| 4650 | assert.Equal(t, "unstar_repository", tool.Name) |
| 4651 | assert.NotEmpty(t, tool.Description) |
| 4652 | assert.Contains(t, schema.Properties, "owner") |
| 4653 | assert.Contains(t, schema.Properties, "repo") |
| 4654 | assert.ElementsMatch(t, schema.Required, []string{"owner", "repo"}) |
| 4655 | |
| 4656 | tests := []struct { |
| 4657 | name string |
| 4658 | mockedClient *http.Client |
| 4659 | requestArgs map[string]any |
| 4660 | expectError bool |
| 4661 | expectedErrMsg string |
| 4662 | }{ |
| 4663 | { |
| 4664 | name: "successful unstar", |
| 4665 | mockedClient: NewMockedHTTPClient( |
| 4666 | WithRequestMatchHandler( |
| 4667 | DeleteUserStarredByOwnerByRepo, |
| 4668 | http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { |
| 4669 | w.WriteHeader(http.StatusNoContent) |
| 4670 | }), |
| 4671 | ), |
| 4672 | ), |
| 4673 | requestArgs: map[string]any{ |
| 4674 | "owner": "testowner", |
| 4675 | "repo": "testrepo", |
| 4676 | }, |
| 4677 | expectError: false, |
| 4678 | }, |
| 4679 | { |
| 4680 | name: "unstar fails", |
| 4681 | mockedClient: NewMockedHTTPClient( |
| 4682 | WithRequestMatchHandler( |
| 4683 | DeleteUserStarredByOwnerByRepo, |
| 4684 | http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { |
| 4685 | w.WriteHeader(http.StatusNotFound) |
| 4686 | _, _ = w.Write([]byte(`{"message": "Not Found"}`)) |
| 4687 | }), |
| 4688 | ), |
| 4689 | ), |
| 4690 | requestArgs: map[string]any{ |
| 4691 | "owner": "testowner", |
| 4692 | "repo": "nonexistent", |
| 4693 | }, |
| 4694 | expectError: true, |
| 4695 | expectedErrMsg: "failed to unstar repository", |
| 4696 | }, |
| 4697 | } |
| 4698 |
nothing calls this directly
no test coverage detected