0
0
mirror of https://github.com/go-gitea/gitea.git synced 2025-07-23 01:11:40 +02:00

run make fmt

This commit is contained in:
Brice Ruth 2025-06-28 16:41:13 -05:00
parent aeaa2c1003
commit 722ac05f41
No known key found for this signature in database
GPG Key ID: 5DFD569B02D44E21
2 changed files with 23 additions and 22 deletions

View File

@ -154,31 +154,31 @@ func ListRuns(ctx *context.APIContext, ownerID, repoID int64) {
if headSHA := ctx.FormString("head_sha"); headSHA != "" {
opts.CommitSHA = headSHA
}
// Handle exclude_pull_requests parameter
if exclude := ctx.FormString("exclude_pull_requests"); exclude != "" {
if exclude == "true" || exclude == "1" {
opts.ExcludePullRequests = true
}
}
// Handle check_suite_id parameter
if checkSuiteID := ctx.FormInt64("check_suite_id"); checkSuiteID > 0 {
opts.CheckSuiteID = checkSuiteID
}
// Handle created parameter for date filtering
if created := ctx.FormString("created"); created != "" {
// Parse the date range in the format like ">=2023-01-01", "<=2023-12-31", or "2023-01-01..2023-12-31"
if strings.Contains(created, "..\u002e") {
// Range format: "2023-01-01..2023-12-31"
dateRange := strings.Split(created, "..")
dateRange := strings.Split(created, "..")
if len(dateRange) == 2 {
startDate, err := time.Parse("2006-01-02", dateRange[0])
if err == nil {
opts.CreatedAfter = startDate
}
endDate, err := time.Parse("2006-01-02", dateRange[1])
if err == nil {
// Set to end of day

View File

@ -12,6 +12,7 @@ import (
"code.gitea.io/gitea/models/unittest"
"code.gitea.io/gitea/services/context"
"code.gitea.io/gitea/services/contexttest"
"github.com/stretchr/testify/assert"
)
@ -79,7 +80,7 @@ func TestListRunsExcludePullRequestsParam(t *testing.T) {
ctx, _ := contexttest.MockAPIContext(t, "user2/repo1")
contexttest.LoadRepo(t, ctx, 1)
contexttest.LoadUser(t, ctx, 2)
// Set up form value
setFormValue(ctx, "exclude_pull_requests", "true")
@ -87,7 +88,7 @@ func TestListRunsExcludePullRequestsParam(t *testing.T) {
opts := actions_model.FindRunOptions{
RepoID: ctx.Repo.Repository.ID,
}
if exclude := ctx.FormString("exclude_pull_requests"); exclude != "" {
if exclude == "true" || exclude == "1" {
opts.ExcludePullRequests = true
@ -101,13 +102,13 @@ func TestListRunsExcludePullRequestsParam(t *testing.T) {
ctx2, _ := contexttest.MockAPIContext(t, "user2/repo1")
contexttest.LoadRepo(t, ctx2, 1)
contexttest.LoadUser(t, ctx2, 2)
setFormValue(ctx2, "exclude_pull_requests", "1")
opts2 := actions_model.FindRunOptions{
RepoID: ctx2.Repo.Repository.ID,
}
if exclude := ctx2.FormString("exclude_pull_requests"); exclude != "" {
if exclude == "true" || exclude == "1" {
opts2.ExcludePullRequests = true
@ -121,13 +122,13 @@ func TestListRunsExcludePullRequestsParam(t *testing.T) {
ctx3, _ := contexttest.MockAPIContext(t, "user2/repo1")
contexttest.LoadRepo(t, ctx3, 1)
contexttest.LoadUser(t, ctx3, 2)
setFormValue(ctx3, "exclude_pull_requests", "false")
opts3 := actions_model.FindRunOptions{
RepoID: ctx3.Repo.Repository.ID,
}
if exclude := ctx3.FormString("exclude_pull_requests"); exclude != "" {
if exclude == "true" || exclude == "1" {
opts3.ExcludePullRequests = true
@ -144,19 +145,19 @@ func TestListRunsCheckSuiteIDParam(t *testing.T) {
unittest.PrepareTestEnv(t)
const testSuiteID int64 = 12345
// Test case: With check_suite_id parameter
ctx, _ := contexttest.MockAPIContext(t, "user2/repo1")
contexttest.LoadRepo(t, ctx, 1)
contexttest.LoadUser(t, ctx, 2)
setFormValue(ctx, "check_suite_id", "12345")
// Call the actual parsing logic from ListRuns
opts := actions_model.FindRunOptions{
RepoID: ctx.Repo.Repository.ID,
}
// This simulates the logic in ListRuns
if checkSuiteID := ctx.FormInt64("check_suite_id"); checkSuiteID > 0 {
opts.CheckSuiteID = checkSuiteID
@ -175,20 +176,20 @@ func TestListRunsCreatedParam(t *testing.T) {
ctx, _ := contexttest.MockAPIContext(t, "user2/repo1")
contexttest.LoadRepo(t, ctx, 1)
contexttest.LoadUser(t, ctx, 2)
setFormValue(ctx, "created", "2023-01-01..2023-12-31")
opts := actions_model.FindRunOptions{
RepoID: ctx.Repo.Repository.ID,
}
// Simulate the date parsing logic from ListRuns
if created := ctx.FormString("created"); created != "" {
if created == "2023-01-01..2023-12-31" {
startDate, _ := time.Parse("2006-01-02", "2023-01-01")
endDate, _ := time.Parse("2006-01-02", "2023-12-31")
endDate = endDate.Add(24*time.Hour - time.Second)
opts.CreatedAfter = startDate
opts.CreatedBefore = endDate
}
@ -198,7 +199,7 @@ func TestListRunsCreatedParam(t *testing.T) {
expectedStart, _ := time.Parse("2006-01-02", "2023-01-01")
expectedEnd, _ := time.Parse("2006-01-02", "2023-12-31")
expectedEnd = expectedEnd.Add(24*time.Hour - time.Second)
assert.Equal(t, expectedStart, opts.CreatedAfter)
assert.Equal(t, expectedEnd, opts.CreatedBefore)
@ -206,13 +207,13 @@ func TestListRunsCreatedParam(t *testing.T) {
ctx2, _ := contexttest.MockAPIContext(t, "user2/repo1")
contexttest.LoadRepo(t, ctx2, 1)
contexttest.LoadUser(t, ctx2, 2)
setFormValue(ctx2, "created", ">=2023-01-01")
opts2 := actions_model.FindRunOptions{
RepoID: ctx2.Repo.Repository.ID,
}
// Simulate the date parsing logic for >= format
if created := ctx2.FormString("created"); created != "" {
if created == ">=2023-01-01" {
@ -231,13 +232,13 @@ func TestListRunsCreatedParam(t *testing.T) {
ctx3, _ := contexttest.MockAPIContext(t, "user2/repo1")
contexttest.LoadRepo(t, ctx3, 1)
contexttest.LoadUser(t, ctx3, 2)
setFormValue(ctx3, "created", "2023-06-15")
opts3 := actions_model.FindRunOptions{
RepoID: ctx3.Repo.Repository.ID,
}
// Simulate the date parsing logic for exact date
if created := ctx3.FormString("created"); created != "" {
if created == "2023-06-15" {