(t *testing.T)
| 2869 | } |
| 2870 | |
| 2871 | func Test_ListBranches(t *testing.T) { |
| 2872 | // Verify tool definition once |
| 2873 | serverTool := ListBranches(translations.NullTranslationHelper) |
| 2874 | tool := serverTool.Tool |
| 2875 | require.NoError(t, toolsnaps.Test(tool.Name, tool)) |
| 2876 | |
| 2877 | schema, ok := tool.InputSchema.(*jsonschema.Schema) |
| 2878 | require.True(t, ok, "InputSchema should be *jsonschema.Schema") |
| 2879 | |
| 2880 | assert.Equal(t, "list_branches", tool.Name) |
| 2881 | assert.NotEmpty(t, tool.Description) |
| 2882 | assert.Contains(t, schema.Properties, "owner") |
| 2883 | assert.Contains(t, schema.Properties, "repo") |
| 2884 | assert.Contains(t, schema.Properties, "page") |
| 2885 | assert.Contains(t, schema.Properties, "perPage") |
| 2886 | assert.ElementsMatch(t, schema.Required, []string{"owner", "repo"}) |
| 2887 | |
| 2888 | // Setup mock branches for success case |
| 2889 | mockBranches := []*github.Branch{ |
| 2890 | { |
| 2891 | Name: github.Ptr("main"), |
| 2892 | Commit: &github.RepositoryCommit{SHA: github.Ptr("abc123")}, |
| 2893 | }, |
| 2894 | { |
| 2895 | Name: github.Ptr("develop"), |
| 2896 | Commit: &github.RepositoryCommit{SHA: github.Ptr("def456")}, |
| 2897 | }, |
| 2898 | } |
| 2899 | |
| 2900 | // Test cases |
| 2901 | tests := []struct { |
| 2902 | name string |
| 2903 | args map[string]any |
| 2904 | mockResponses []MockBackendOption |
| 2905 | wantErr bool |
| 2906 | errContains string |
| 2907 | }{ |
| 2908 | { |
| 2909 | name: "success", |
| 2910 | args: map[string]any{ |
| 2911 | "owner": "owner", |
| 2912 | "repo": "repo", |
| 2913 | "page": float64(2), |
| 2914 | }, |
| 2915 | mockResponses: []MockBackendOption{ |
| 2916 | WithRequestMatch( |
| 2917 | GetReposBranchesByOwnerByRepo, |
| 2918 | mockBranches, |
| 2919 | ), |
| 2920 | }, |
| 2921 | wantErr: false, |
| 2922 | }, |
| 2923 | { |
| 2924 | name: "missing owner", |
| 2925 | args: map[string]any{ |
| 2926 | "repo": "repo", |
| 2927 | }, |
| 2928 | mockResponses: []MockBackendOption{}, |
nothing calls this directly
no test coverage detected