(t *testing.T)
| 2987 | } |
| 2988 | |
| 2989 | func Test_DeleteFile(t *testing.T) { |
| 2990 | // Verify tool definition once |
| 2991 | serverTool := DeleteFile(translations.NullTranslationHelper) |
| 2992 | tool := serverTool.Tool |
| 2993 | require.NoError(t, toolsnaps.Test(tool.Name, tool)) |
| 2994 | |
| 2995 | schema, ok := tool.InputSchema.(*jsonschema.Schema) |
| 2996 | require.True(t, ok, "InputSchema should be *jsonschema.Schema") |
| 2997 | |
| 2998 | assert.Equal(t, "delete_file", tool.Name) |
| 2999 | assert.NotEmpty(t, tool.Description) |
| 3000 | assert.Contains(t, schema.Properties, "owner") |
| 3001 | assert.Contains(t, schema.Properties, "repo") |
| 3002 | assert.Contains(t, schema.Properties, "path") |
| 3003 | assert.Contains(t, schema.Properties, "message") |
| 3004 | assert.Contains(t, schema.Properties, "branch") |
| 3005 | // SHA is no longer required since we're using Git Data API |
| 3006 | assert.ElementsMatch(t, schema.Required, []string{"owner", "repo", "path", "message", "branch"}) |
| 3007 | |
| 3008 | // Setup mock objects for Git Data API |
| 3009 | mockRef := &github.Reference{ |
| 3010 | Ref: github.Ptr("refs/heads/main"), |
| 3011 | Object: &github.GitObject{ |
| 3012 | SHA: github.Ptr("abc123"), |
| 3013 | }, |
| 3014 | } |
| 3015 | |
| 3016 | mockCommit := &github.Commit{ |
| 3017 | SHA: github.Ptr("abc123"), |
| 3018 | Tree: &github.Tree{ |
| 3019 | SHA: github.Ptr("def456"), |
| 3020 | }, |
| 3021 | } |
| 3022 | |
| 3023 | mockTree := &github.Tree{ |
| 3024 | SHA: github.Ptr("ghi789"), |
| 3025 | } |
| 3026 | |
| 3027 | mockNewCommit := &github.Commit{ |
| 3028 | SHA: github.Ptr("jkl012"), |
| 3029 | Message: github.Ptr("Delete example file"), |
| 3030 | HTMLURL: github.Ptr("https://github.com/owner/repo/commit/jkl012"), |
| 3031 | } |
| 3032 | |
| 3033 | tests := []struct { |
| 3034 | name string |
| 3035 | mockedClient *http.Client |
| 3036 | requestArgs map[string]any |
| 3037 | expectError bool |
| 3038 | expectedCommitSHA string |
| 3039 | expectedErrMsg string |
| 3040 | }{ |
| 3041 | { |
| 3042 | name: "successful file deletion using Git Data API", |
| 3043 | mockedClient: NewMockedHTTPClient( |
| 3044 | // Get branch reference |
| 3045 | WithRequestMatch( |
| 3046 | GetReposGitRefByOwnerByRepoByRef, |
nothing calls this directly
no test coverage detected