"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "api/queries_pr_test.go" between
gh-cli-1.10.3.tar.gz and gh-cli-1.11.0.tar.gz

About: GitHub CLI is GitHub’s official command line tool.

queries_pr_test.go  (gh-cli-1.10.3):queries_pr_test.go  (gh-cli-1.11.0)
package api package api
import ( import (
"reflect" "encoding/json"
"testing" "testing"
"github.com/MakeNowJust/heredoc" "github.com/MakeNowJust/heredoc"
"github.com/cli/cli/internal/ghrepo" "github.com/cli/cli/internal/ghrepo"
"github.com/cli/cli/pkg/httpmock" "github.com/cli/cli/pkg/httpmock"
"github.com/stretchr/testify/assert"
) )
func TestBranchDeleteRemote(t *testing.T) { func TestBranchDeleteRemote(t *testing.T) {
var tests = []struct { var tests = []struct {
name string name string
responseStatus int responseStatus int
responseBody string responseBody string
expectError bool expectError bool
}{ }{
{ {
skipping to change at line 151 skipping to change at line 152
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
fakeHTTP := &httpmock.Registry{} fakeHTTP := &httpmock.Registry{}
httpClient := NewHTTPClient(ReplaceTripper(fakeHTTP)) httpClient := NewHTTPClient(ReplaceTripper(fakeHTTP))
for query, resp := range tt.queryResponse { for query, resp := range tt.queryResponse {
fakeHTTP.Register(httpmock.GraphQL(query), httpmo ck.StringResponse(resp)) fakeHTTP.Register(httpmock.GraphQL(query), httpmo ck.StringResponse(resp))
} }
gotPrFeatures, err := determinePullRequestFeatures(httpCl ient, tt.hostname) gotPrFeatures, err := determinePullRequestFeatures(httpCl ient, tt.hostname)
if (err != nil) != tt.wantErr { if tt.wantErr {
t.Errorf("determinePullRequestFeatures() error = assert.Error(t, err)
%v, wantErr %v", err, tt.wantErr)
return return
} else {
assert.NoError(t, err)
} }
if !reflect.DeepEqual(gotPrFeatures, tt.wantPrFeatures) { assert.Equal(t, tt.wantPrFeatures, gotPrFeatures)
t.Errorf("determinePullRequestFeatures() = %v, wa })
nt %v", gotPrFeatures, tt.wantPrFeatures) }
} }
func Test_Logins(t *testing.T) {
rr := ReviewRequests{}
var tests = []struct {
name string
requestedReviews string
want []string
}{
{
name: "no requested reviewers",
requestedReviews: `{"nodes": []}`,
want: []string{},
},
{
name: "user",
requestedReviews: `{"nodes": [
{
"requestedreviewer": {
"__typename": "User", "login": "t
estuser"
}
}
]}`,
want: []string{"testuser"},
},
{
name: "team",
requestedReviews: `{"nodes": [
{
"requestedreviewer": {
"__typename": "Team",
"name": "Test Team",
"slug": "test-team",
"organization": {"login": "myorg"
}
}
}
]}`,
want: []string{"myorg/test-team"},
},
{
name: "multiple users and teams",
requestedReviews: `{"nodes": [
{
"requestedreviewer": {
"__typename": "User", "login": "u
ser1"
}
},
{
"requestedreviewer": {
"__typename": "User", "login": "u
ser2"
}
},
{
"requestedreviewer": {
"__typename": "Team",
"name": "Test Team",
"slug": "test-team",
"organization": {"login": "myorg"
}
}
},
{
"requestedreviewer": {
"__typename": "Team",
"name": "Dev Team",
"slug": "dev-team",
"organization": {"login": "myorg"
}
}
}
]}`,
want: []string{"user1", "user2", "myorg/test-team", "myor
g/dev-team"},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
err := json.Unmarshal([]byte(tt.requestedReviews), &rr)
assert.NoError(t, err, "Failed to unmarshal json string a
s ReviewRequests")
logins := rr.Logins()
assert.Equal(t, tt.want, logins)
}) })
} }
} }
 End of changes. 5 change blocks. 
8 lines changed or deleted 96 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)