generated from cloudoperators/repository-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ca50f9c
commit f4ab534
Showing
5 changed files
with
195 additions
and
56 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
internal/api/graphql/graph/queryCollection/issue/listIssues.graphql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Greenhouse contributors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
query ($filter: IssueFilter, $first: Int, $after: String) { | ||
Issues ( | ||
filter: $filter, | ||
first: $first, | ||
after: $after | ||
) { | ||
totalCount | ||
edges { | ||
node { | ||
id | ||
type | ||
primaryName | ||
description | ||
lastModified | ||
metadata { | ||
created_at | ||
created_by | ||
deleted_at | ||
updated_at | ||
updated_by | ||
} | ||
} | ||
cursor | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
// SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Greenhouse contributors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package e2e_common | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"os" | ||
|
||
"github.com/cloudoperators/heureka/internal/api/graphql/graph/model" | ||
util2 "github.com/cloudoperators/heureka/pkg/util" | ||
|
||
"github.com/machinebox/graphql" | ||
. "github.com/onsi/gomega" | ||
"github.com/sirupsen/logrus" | ||
) | ||
|
||
type Issue struct { | ||
PrimaryName string | ||
Description string | ||
Type string | ||
} | ||
|
||
func QueryCreateIssue(port string, issue Issue) *model.Issue { | ||
client := graphql.NewClient(fmt.Sprintf("http://localhost:%s/query", port)) | ||
|
||
//@todo may need to make this more fault proof?! What if the test is executed from the root dir? does it still work? | ||
b, err := os.ReadFile("../api/graphql/graph/queryCollection/issue/create.graphql") | ||
Expect(err).To(BeNil()) | ||
str := string(b) | ||
req := graphql.NewRequest(str) | ||
|
||
req.Var("input", map[string]interface{}{ | ||
"primaryName": issue.PrimaryName, | ||
"description": issue.Description, | ||
"type": issue.Type, | ||
}) | ||
|
||
req.Header.Set("Cache-Control", "no-cache") | ||
ctx := context.Background() | ||
|
||
var respData struct { | ||
Issue model.Issue `json:"createIssue"` | ||
} | ||
if err := util2.RequestWithBackoff(func() error { return client.Run(ctx, req, &respData) }); err != nil { | ||
logrus.WithError(err).WithField("request", req).Fatalln("Error while unmarshaling") | ||
} | ||
return &respData.Issue | ||
} | ||
|
||
func QueryUpdateIssue(port string, issue Issue, iid string) *model.Issue { | ||
// create a queryCollection (safe to share across requests) | ||
client := graphql.NewClient(fmt.Sprintf("http://localhost:%s/query", port)) | ||
|
||
//@todo may need to make this more fault proof?! What if the test is executed from the root dir? does it still work? | ||
b, err := os.ReadFile("../api/graphql/graph/queryCollection/issue/update.graphql") | ||
Expect(err).To(BeNil()) | ||
str := string(b) | ||
req := graphql.NewRequest(str) | ||
|
||
req.Var("id", iid) | ||
req.Var("input", map[string]string{ | ||
"description": issue.Description, | ||
"type": issue.Type, | ||
}) | ||
|
||
req.Header.Set("Cache-Control", "no-cache") | ||
ctx := context.Background() | ||
|
||
var respData struct { | ||
Issue model.Issue `json:"updateIssue"` | ||
} | ||
if err := util2.RequestWithBackoff(func() error { return client.Run(ctx, req, &respData) }); err != nil { | ||
logrus.WithError(err).WithField("request", req).Fatalln("Error while unmarshaling") | ||
} | ||
return &respData.Issue | ||
} | ||
|
||
func QueryGetIssue(port string, issuePrimaryName string) *model.IssueConnection { | ||
// create a queryCollection (safe to share across requests) | ||
client := graphql.NewClient(fmt.Sprintf("http://localhost:%s/query", port)) | ||
|
||
//@todo may need to make this more fault proof?! What if the test is executed from the root dir? does it still work? | ||
b, err := os.ReadFile("../api/graphql/graph/queryCollection/issue/listIssues.graphql") | ||
Expect(err).To(BeNil()) | ||
str := string(b) | ||
req := graphql.NewRequest(str) | ||
|
||
req.Var("filter", map[string]string{"primaryName": issuePrimaryName}) | ||
req.Var("first", 1) | ||
req.Var("after", "0") | ||
|
||
req.Header.Set("Cache-Control", "no-cache") | ||
ctx := context.Background() | ||
|
||
var respData struct { | ||
Issues model.IssueConnection `json:"Issues"` | ||
} | ||
if err := util2.RequestWithBackoff(func() error { return client.Run(ctx, req, &respData) }); err != nil { | ||
logrus.WithError(err).WithField("request", req).Fatalln("Error while unmarshaling") | ||
} | ||
return &respData.Issues | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters