Refactor: Improvements for branch tests
While integrating the GitLab API for our project using this library, I noticed a few issues and inconsistencies in the branch tests and documentation:
- TestBranchesService_ListBranchesWithSearch
- This test does not actually validate the search parameter, as the filtering is handled on the GitLab side, not by the client library. Therefore, the assert.Len() call doesn't make sense in this context.
- Additionally, the test data file (testdata/list_branches.json) contains only one branch. If more branches were added, we would see that this test doesn't work as expected.
- TestBranchesService_ListBranchesWithRegex
- Similar to the previous case, the assert.Len() check is ineffective because the regex query parameter does not influence the test output. It may be best to remove this assertion entirely.
- Helper Function: mustWriteHTTPResponse
- In the mustWriteHTTPResponse helper, it would be better to close the file using defer, ensuring that resources are properly released even in the case of an error.
- Mock Example in README.md
- The example provided in the README.md appears to be outdated. It references a List method:
 // Setup expectations
    client.MockClusterAgents.EXPECT().
        List(gomock.Any(), 123, nil).
        Return([]*gitlab.ClusterAgent{{ID: 1}}, nil)However, the List method does not exist. It looks like we should be calling ListAgents() and updating the return parameters accordingly.