1
0
mirror of https://github.com/woodpecker-ci/woodpecker.git synced 2025-07-12 22:21:40 +02:00

Fix events filter in GetPipelines API (#4498)

This commit is contained in:
Robert Kaussow
2024-12-01 23:32:46 +01:00
committed by GitHub
parent 3c31284e7b
commit 8cfb8f93fa
2 changed files with 19 additions and 1 deletions

View File

@ -96,6 +96,24 @@ func TestGetPipelines(t *testing.T) {
assert.Equal(t, http.StatusOK, c.Writer.Status())
})
t.Run("should filter pipelines by events", func(t *testing.T) {
pipelines := []*model.Pipeline{fakePipeline}
mockStore := store_mocks.NewStore(t)
mockStore.On("GetPipelineList", mock.Anything, mock.Anything, mock.Anything).Return(pipelines, nil)
w := httptest.NewRecorder()
c, _ := gin.CreateTestContext(w)
c.Set("store", mockStore)
c.Request, _ = http.NewRequest(http.MethodGet, "/?event=push,pull_request", nil)
GetPipelines(c)
mockStore.AssertCalled(t, "GetPipelineList", mock.Anything, mock.Anything, &model.PipelineFilter{
Events: model.WebhookEventList{model.EventPush, model.EventPull},
})
assert.Equal(t, http.StatusOK, c.Writer.Status())
})
}
func TestDeletePipeline(t *testing.T) {