Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore: add missing mock for gitops (#13114)

ecmadao526c566ecea5
diff --git a/backend/tests/fake/azure.go b/backend/tests/fake/azure.go
index 64759383b5..7ebd4325fd 100644
--- a/backend/tests/fake/azure.go
+++ b/backend/tests/fake/azure.go
@@ -62,7 +62,9 @@ func NewAzure(port int) VCSProvider {
repo := e.Group("/:organization/:project/_apis/git/repositories/:repo")
repo.GET("/stats/branches", az.getRepositoryBranch)
+ repo.GET("/pullRequests/:pr/threads", az.listIssueComments)
repo.POST("/pullRequests/:pr/threads", az.createIssueComment)
+ repo.PATCH("/pullRequests/:pr/threads/:thread", az.updateIssueComment)
repo.GET("/commits/:commit/changes", az.getCommitChanges)
repo.GET("/items", az.readRepositoryFile)
@@ -217,10 +219,26 @@ func (az *Azure) getRepositoryBranch(c echo.Context) error {
return az.getResponse(c, r.refs[fmt.Sprintf("refs/heads/%s", branchName)])
}
+func (*Azure) listIssueComments(c echo.Context) error {
+ type listComment struct {
+ Value []*azure.PullRequestThread `json:"value"`
+ }
+
+ buf, err := json.Marshal(listComment{})
+ if err != nil {
+ return c.String(http.StatusInternalServerError, fmt.Sprintf("failed to marshal response body for list comments: %v", err))
+ }
+ return c.String(http.StatusOK, string(buf))
+}
+
func (*Azure) createIssueComment(echo.Context) error {
return nil
}
+func (*Azure) updateIssueComment(echo.Context) error {
+ return nil
+}
+
func (az *Azure) validRepository(c echo.Context) (*azureRepositoryData, error) {
repositoryID := fmt.Sprintf("%s/%s/%s", c.Param("organization"), c.Param("project"), c.Param("repo"))
r, ok := az.repositories[repositoryID]
diff --git a/backend/tests/fake/bitbucket.go b/backend/tests/fake/bitbucket.go
index 63e7b4faa3..a3ec2d2f5d 100644
--- a/backend/tests/fake/bitbucket.go
+++ b/backend/tests/fake/bitbucket.go
@@ -64,7 +64,9 @@ func NewBitbucket(port int) VCSProvider {
g.GET("/repositories/:owner/:repo/src/:ref/:filepath", bb.getRepositoryContent)
g.GET("/repositories/:owner/:repo/refs/branches/:branchName", bb.getRepositoryBranch)
g.GET("/repositories/:owner/:repo/pullrequests/:prID/diffstat", bb.listPullRequestFile)
- g.GET("/repositories/:owner/:repo/pullrequests/:prID/comments", bb.createPullRequestComment)
+ g.GET("/repositories/:owner/:repo/pullrequests/:prID/comments", bb.listPullRequestComment)
+ g.POST("/repositories/:owner/:repo/pullrequests/:prID/comments", bb.createPullRequestComment)
+ g.PUT("/repositories/:owner/:repo/pullrequests/:prID/comments/:comment", bb.updatePullRequestComment)
return bb
}
@@ -345,3 +347,18 @@ func (bb *Bitbucket) listPullRequestFile(c echo.Context) error {
func (*Bitbucket) createPullRequestComment(echo.Context) error {
return nil
}
+
+func (*Bitbucket) updatePullRequestComment(echo.Context) error {
+ return nil
+}
+
+func (*Bitbucket) listPullRequestComment(c echo.Context) error {
+ type listComment struct {
+ Values []*bitbucket.Comment `json:"values"`
+ }
+ buf, err := json.Marshal(listComment{})
+ if err != nil {
+ return c.String(http.StatusInternalServerError, fmt.Sprintf("failed to marshal response body: %v", err))
+ }
+ return c.String(http.StatusOK, string(buf))
+}
diff --git a/backend/tests/fake/github.go b/backend/tests/fake/github.go
index b9d1048d0f..3552de7ec8 100644
--- a/backend/tests/fake/github.go
+++ b/backend/tests/fake/github.go
@@ -68,7 +68,9 @@ func NewGitHub(port int) VCSProvider {
g.GET("/repos/:owner/:repo/contents/:filePath", gh.readRepositoryFile)
g.GET("/repos/:owner/:repo/git/ref/heads/:branchName", gh.getRepositoryBranch)
g.GET("/repos/:owner/:repo/pulls/:prID/files", gh.listPullRequestFile)
+ g.GET("/repos/:owner/:repo/issues/:prID/comments", gh.listIssueComment)
g.POST("/repos/:owner/:repo/issues/:prID/comments", gh.createIssueComment)
+ g.PATCH("/repos/:owner/:repo/issues/:prID/comments", gh.updateIssueComment)
return gh
}
@@ -212,6 +214,19 @@ func (*GitHub) createIssueComment(echo.Context) error {
return nil
}
+func (*GitHub) updateIssueComment(echo.Context) error {
+ return nil
+}
+
+func (*GitHub) listIssueComment(c echo.Context) error {
+ comments := []github.Comment{}
+ buf, err := json.Marshal(comments)
+ if err != nil {
+ return c.String(http.StatusInternalServerError, fmt.Sprintf("failed to marshal response body: %v", err))
+ }
+ return c.String(http.StatusOK, string(buf))
+}
+
func (gh *GitHub) validRepository(c echo.Context) (*githubRepositoryData, error) {
repositoryID := fmt.Sprintf("%s/%s", c.Param("owner"), c.Param("repo"))
r, ok := gh.repositories[repositoryID]
diff --git a/backend/tests/fake/gitlab.go b/backend/tests/fake/gitlab.go
index 26c5652b47..8d294906e8 100644
--- a/backend/tests/fake/gitlab.go
+++ b/backend/tests/fake/gitlab.go
@@ -69,7 +69,9 @@ func NewGitLab(port int) VCSProvider {
projectGroup.POST("/projects/:id/repository/branches", gl.createProjectBranch)
projectGroup.POST("/projects/:id/merge_requests", gl.createProjectPullRequest)
projectGroup.GET("/projects/:id/merge_requests/:mrID/changes", gl.getMergeRequestChanges)
- projectGroup.GET("/projects/:id/merge_requests/:mrID/notes", gl.createMergeRequestComment)
+ projectGroup.GET("/projects/:id/merge_requests/:mrID/notes", gl.listMergeRequestComment)
+ projectGroup.POST("/projects/:id/merge_requests/:mrID/notes", gl.createMergeRequestComment)
+ projectGroup.PUT("/projects/:id/merge_requests/:mrID/notes/:note", gl.updateMergeRequestComment)
return gl
}
@@ -353,6 +355,19 @@ func (*GitLab) createMergeRequestComment(echo.Context) error {
return nil
}
+func (*GitLab) updateMergeRequestComment(echo.Context) error {
+ return nil
+}
+
+func (*GitLab) listMergeRequestComment(c echo.Context) error {
+ comments := []*gitlab.Comment{}
+ buf, err := json.Marshal(comments)
+ if err != nil {
+ return c.String(http.StatusInternalServerError, fmt.Sprintf("failed to marshal response body: %v", err))
+ }
+ return c.String(http.StatusOK, string(buf))
+}
+
// SendWebhookPush sends out a webhook for a push event for the GitLab project
// using given payload.
func (gl *GitLab) SendWebhookPush(projectID string, payload []byte) error {