Add GetRepoByID #511
|
@ -382,6 +382,13 @@ func (c *Client) GetRepo(owner, reponame string) (*Repository, *Response, error)
|
|||
return repo, resp, err
|
||||
}
|
||||
|
||||
// GetRepoByID returns information of a repository by a giver repository ID.
|
||||
func (c *Client) GetRepoByID(id int64) (*Repository, *Response, error) {
|
||||
repo := new(Repository)
|
||||
resp, err := c.getParsedResponse("GET", fmt.Sprintf("/repositories/%d", id), nil, nil, repo)
|
||||
return repo, resp, err
|
||||
}
|
||||
|
||||
// EditRepoOption options when editing a repository's properties
|
||||
type EditRepoOption struct {
|
||||
// name of the repository
|
||||
|
|
|
@ -157,6 +157,20 @@ func TestGetArchiveReader(t *testing.T) {
|
|||
assert.EqualValues(t, nBytes, len(archive.Bytes()))
|
||||
}
|
||||
|
||||
func TestGetRepoByID(t *testing.T) {
|
||||
log.Println("== TestGetRepoByID ==")
|
||||
c := newTestClient()
|
||||
testrepo, _ := createTestRepo(t, "TestGetRepoByID", c)
|
||||
|
||||
6543 marked this conversation as resolved
Outdated
6543
commented
Outdated
Review
```diff
-
+
```
|
||||
repo, _, err := c.GetRepoByID(testrepo.ID)
|
||||
assert.NoError(t, err)
|
||||
assert.NotNil(t, repo)
|
||||
6543 marked this conversation as resolved
Outdated
6543
commented
can you add can you add `assert.EqualValues(t, testrepo.ID, repo.ID)` - just to make sure it do what is expected
@J0Nes90
|
||||
assert.EqualValues(t, testrepo.ID, repo.ID)
|
||||
|
||||
_, err = c.DeleteRepo(repo.Owner.UserName, repo.Name)
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
|
||||
// standard func to create a init repo for test routines
|
||||
func createTestRepo(t *testing.T, name string, c *Client) (*Repository, error) {
|
||||
user, _, uErr := c.GetMyUserInfo()
|
||||
|
|
Loading…
Reference in New Issue
Block a user