2018-11-21 20:56:12 +03:00
|
|
|
package graphql
|
2018-09-26 16:55:14 +03:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2020-02-06 00:03:19 +03:00
|
|
|
"github.com/99designs/gqlgen/client"
|
2019-04-05 02:15:52 +03:00
|
|
|
|
2018-09-26 16:55:14 +03:00
|
|
|
"github.com/MichaelMure/git-bug/graphql/models"
|
2019-02-16 15:48:46 +03:00
|
|
|
"github.com/MichaelMure/git-bug/misc/random_bugs"
|
|
|
|
"github.com/MichaelMure/git-bug/repository"
|
2018-09-26 16:55:14 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestQueries(t *testing.T) {
|
2019-05-27 22:14:55 +03:00
|
|
|
repo := repository.CreateTestRepo(false)
|
|
|
|
defer repository.CleanupTestRepos(t, repo)
|
|
|
|
|
|
|
|
random_bugs.FillRepoWithSeed(repo, 10, 42)
|
2018-09-26 16:55:14 +03:00
|
|
|
|
2018-11-21 20:56:12 +03:00
|
|
|
handler, err := NewHandler(repo)
|
2018-09-26 16:55:14 +03:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2020-02-06 01:42:49 +03:00
|
|
|
c := client.New(handler)
|
2018-09-26 16:55:14 +03:00
|
|
|
|
|
|
|
query := `
|
2019-04-05 02:15:52 +03:00
|
|
|
query {
|
2018-09-26 16:55:14 +03:00
|
|
|
defaultRepository {
|
|
|
|
allBugs(first: 2) {
|
|
|
|
pageInfo {
|
|
|
|
endCursor
|
|
|
|
hasNextPage
|
|
|
|
startCursor
|
|
|
|
hasPreviousPage
|
|
|
|
}
|
|
|
|
nodes{
|
|
|
|
author {
|
|
|
|
name
|
|
|
|
email
|
|
|
|
avatarUrl
|
|
|
|
}
|
|
|
|
|
|
|
|
createdAt
|
|
|
|
humanId
|
|
|
|
id
|
|
|
|
lastEdit
|
|
|
|
status
|
|
|
|
title
|
2019-04-05 02:13:17 +03:00
|
|
|
|
|
|
|
actors(first: 10) {
|
|
|
|
pageInfo {
|
|
|
|
endCursor
|
|
|
|
hasNextPage
|
|
|
|
startCursor
|
|
|
|
hasPreviousPage
|
|
|
|
}
|
2019-04-05 02:15:52 +03:00
|
|
|
nodes {
|
|
|
|
id
|
|
|
|
humanId
|
|
|
|
name
|
|
|
|
displayName
|
|
|
|
}
|
|
|
|
}
|
2019-04-05 02:13:17 +03:00
|
|
|
|
2019-04-05 02:15:52 +03:00
|
|
|
participants(first: 10) {
|
2019-04-05 02:13:17 +03:00
|
|
|
pageInfo {
|
|
|
|
endCursor
|
|
|
|
hasNextPage
|
|
|
|
startCursor
|
|
|
|
hasPreviousPage
|
|
|
|
}
|
2019-04-05 02:15:52 +03:00
|
|
|
nodes {
|
|
|
|
id
|
|
|
|
humanId
|
|
|
|
name
|
|
|
|
displayName
|
|
|
|
}
|
|
|
|
}
|
2018-09-26 16:55:14 +03:00
|
|
|
|
|
|
|
comments(first: 2) {
|
|
|
|
pageInfo {
|
|
|
|
endCursor
|
|
|
|
hasNextPage
|
|
|
|
startCursor
|
|
|
|
hasPreviousPage
|
|
|
|
}
|
|
|
|
nodes {
|
|
|
|
files
|
|
|
|
message
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
operations(first: 20) {
|
|
|
|
pageInfo {
|
|
|
|
endCursor
|
|
|
|
hasNextPage
|
|
|
|
startCursor
|
|
|
|
hasPreviousPage
|
|
|
|
}
|
|
|
|
nodes {
|
|
|
|
author {
|
|
|
|
name
|
|
|
|
email
|
|
|
|
avatarUrl
|
|
|
|
}
|
|
|
|
date
|
|
|
|
... on CreateOperation {
|
|
|
|
title
|
|
|
|
message
|
|
|
|
files
|
|
|
|
}
|
|
|
|
... on SetTitleOperation {
|
|
|
|
title
|
|
|
|
was
|
|
|
|
}
|
|
|
|
... on AddCommentOperation {
|
|
|
|
files
|
|
|
|
message
|
|
|
|
}
|
|
|
|
... on SetStatusOperation {
|
|
|
|
status
|
|
|
|
}
|
|
|
|
... on LabelChangeOperation {
|
2019-05-16 01:01:43 +03:00
|
|
|
added {
|
|
|
|
name
|
|
|
|
color {
|
|
|
|
R
|
|
|
|
G
|
|
|
|
B
|
|
|
|
}
|
|
|
|
}
|
|
|
|
removed {
|
|
|
|
name
|
|
|
|
color {
|
|
|
|
R
|
|
|
|
G
|
|
|
|
B
|
|
|
|
}
|
|
|
|
}
|
2018-09-26 16:55:14 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}`
|
|
|
|
|
2019-03-31 23:32:35 +03:00
|
|
|
type Identity struct {
|
2019-04-05 02:13:17 +03:00
|
|
|
Id string `json:"id"`
|
|
|
|
HumanId string `json:"humanId"`
|
|
|
|
Name string `json:"name"`
|
|
|
|
Email string `json:"email"`
|
|
|
|
AvatarUrl string `json:"avatarUrl"`
|
|
|
|
DisplayName string `json:"displayName"`
|
2018-09-26 16:55:14 +03:00
|
|
|
}
|
|
|
|
|
2019-05-16 01:01:43 +03:00
|
|
|
type Label struct {
|
|
|
|
Name string
|
|
|
|
Color struct {
|
|
|
|
R, G, B int
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-26 16:55:14 +03:00
|
|
|
var resp struct {
|
|
|
|
DefaultRepository struct {
|
|
|
|
AllBugs struct {
|
|
|
|
PageInfo models.PageInfo
|
|
|
|
Nodes []struct {
|
2019-04-05 02:13:17 +03:00
|
|
|
Author Identity
|
|
|
|
CreatedAt string `json:"createdAt"`
|
|
|
|
HumanId string `json:"humanId"`
|
|
|
|
Id string
|
|
|
|
LastEdit string `json:"lastEdit"`
|
|
|
|
Status string
|
|
|
|
Title string
|
|
|
|
|
|
|
|
Actors struct {
|
|
|
|
PageInfo models.PageInfo
|
|
|
|
Nodes []Identity
|
|
|
|
}
|
|
|
|
|
|
|
|
Participants struct {
|
|
|
|
PageInfo models.PageInfo
|
|
|
|
Nodes []Identity
|
|
|
|
}
|
2018-09-26 16:55:14 +03:00
|
|
|
|
|
|
|
Comments struct {
|
|
|
|
PageInfo models.PageInfo
|
|
|
|
Nodes []struct {
|
|
|
|
Files []string
|
|
|
|
Message string
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Operations struct {
|
|
|
|
PageInfo models.PageInfo
|
|
|
|
Nodes []struct {
|
2019-03-31 23:32:35 +03:00
|
|
|
Author Identity
|
2018-09-26 16:55:14 +03:00
|
|
|
Date string
|
|
|
|
Title string
|
|
|
|
Files []string
|
|
|
|
Message string
|
|
|
|
Was string
|
|
|
|
Status string
|
2019-05-16 01:01:43 +03:00
|
|
|
Added []Label
|
|
|
|
Removed []Label
|
2018-09-26 16:55:14 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
c.MustPost(query, &resp)
|
|
|
|
}
|