github.com/cli/cli@v1.14.1-0.20210902173923-1af6a669e342/api/query_builder_test.go (about) 1 package api 2 3 import "testing" 4 5 func TestPullRequestGraphQL(t *testing.T) { 6 tests := []struct { 7 name string 8 fields []string 9 want string 10 }{ 11 { 12 name: "empty", 13 fields: []string(nil), 14 want: "", 15 }, 16 { 17 name: "simple fields", 18 fields: []string{"number", "title"}, 19 want: "number,title", 20 }, 21 { 22 name: "fields with nested structures", 23 fields: []string{"author", "assignees"}, 24 want: "author{login},assignees(first:100){nodes{id,login,name},totalCount}", 25 }, 26 { 27 name: "compressed query", 28 fields: []string{"files"}, 29 want: "files(first: 100) {nodes {additions,deletions,path}}", 30 }, 31 } 32 for _, tt := range tests { 33 t.Run(tt.name, func(t *testing.T) { 34 if got := PullRequestGraphQL(tt.fields); got != tt.want { 35 t.Errorf("PullRequestGraphQL() = %v, want %v", got, tt.want) 36 } 37 }) 38 } 39 }