Small nitpicky polish
This commit is contained in:
parent
a612f06dee
commit
761fa94831
2 changed files with 16 additions and 20 deletions
|
|
@ -168,7 +168,7 @@ func (r ReviewRequests) Logins() []string {
|
|||
logins := make([]string, len(r.Nodes))
|
||||
for i, a := range r.Nodes {
|
||||
if a.RequestedReviewer.TypeName == teamTypeName {
|
||||
logins[i] = a.RequestedReviewer.Organization.Login + "/" + a.RequestedReviewer.Slug
|
||||
logins[i] = fmt.Sprintf("%s/%s", a.RequestedReviewer.Organization.Login, a.RequestedReviewer.Slug)
|
||||
} else {
|
||||
logins[i] = a.RequestedReviewer.Login
|
||||
}
|
||||
|
|
@ -403,8 +403,8 @@ func PullRequestStatus(client *Client, repo ghrepo.Interface, options StatusOpti
|
|||
queryPrefix := `
|
||||
query PullRequestStatus($owner: String!, $repo: String!, $headRefName: String!, $viewerQuery: String!, $reviewerQuery: String!, $per_page: Int = 10) {
|
||||
repository(owner: $owner, name: $repo) {
|
||||
defaultBranchRef {
|
||||
name
|
||||
defaultBranchRef {
|
||||
name
|
||||
}
|
||||
pullRequests(headRefName: $headRefName, first: $per_page, orderBy: { field: CREATED_AT, direction: DESC }) {
|
||||
totalCount
|
||||
|
|
@ -420,8 +420,8 @@ func PullRequestStatus(client *Client, repo ghrepo.Interface, options StatusOpti
|
|||
queryPrefix = `
|
||||
query PullRequestStatus($owner: String!, $repo: String!, $number: Int!, $viewerQuery: String!, $reviewerQuery: String!, $per_page: Int = 10) {
|
||||
repository(owner: $owner, name: $repo) {
|
||||
defaultBranchRef {
|
||||
name
|
||||
defaultBranchRef {
|
||||
name
|
||||
}
|
||||
pullRequest(number: $number) {
|
||||
...prWithReviews
|
||||
|
|
|
|||
|
|
@ -2,12 +2,12 @@ package api
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/MakeNowJust/heredoc"
|
||||
"github.com/cli/cli/internal/ghrepo"
|
||||
"github.com/cli/cli/pkg/httpmock"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestBranchDeleteRemote(t *testing.T) {
|
||||
|
|
@ -149,13 +149,13 @@ func Test_determinePullRequestFeatures(t *testing.T) {
|
|||
}
|
||||
|
||||
gotPrFeatures, err := determinePullRequestFeatures(httpClient, tt.hostname)
|
||||
if (err != nil) != tt.wantErr {
|
||||
t.Errorf("determinePullRequestFeatures() error = %v, wantErr %v", err, tt.wantErr)
|
||||
if tt.wantErr {
|
||||
assert.Error(t, err)
|
||||
return
|
||||
} else {
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
if !reflect.DeepEqual(gotPrFeatures, tt.wantPrFeatures) {
|
||||
t.Errorf("determinePullRequestFeatures() = %v, want %v", gotPrFeatures, tt.wantPrFeatures)
|
||||
}
|
||||
assert.Equal(t, tt.wantPrFeatures, gotPrFeatures)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
@ -168,9 +168,9 @@ func Test_Logins(t *testing.T) {
|
|||
want []string
|
||||
}{
|
||||
{
|
||||
name: "no requested reviewers",
|
||||
name: "no requested reviewers",
|
||||
requestedReviews: `{"nodes": []}`,
|
||||
want: []string{},
|
||||
want: []string{},
|
||||
},
|
||||
{
|
||||
name: "user",
|
||||
|
|
@ -234,13 +234,9 @@ func Test_Logins(t *testing.T) {
|
|||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
err := json.Unmarshal([]byte(tt.requestedReviews), &rr)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to unmarshal json string as ReviewRequests: %v", tt.requestedReviews)
|
||||
}
|
||||
got := rr.Logins()
|
||||
if !reflect.DeepEqual(got, tt.want) {
|
||||
t.Fatalf("Unexpected results: expected %v but got %v", tt.want, got)
|
||||
}
|
||||
assert.NoError(t, err, "Failed to unmarshal json string as ReviewRequests")
|
||||
logins := rr.Logins()
|
||||
assert.Equal(t, tt.want, logins)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue