0
0
mirror of https://github.com/go-gitea/gitea.git synced 2025-07-22 23:02:07 +02:00
gitea/models/actions/run_list_test.go
Brice Ruth 1b9b410c5d
Remove non-functional CheckSuiteID parameter support
The CheckSuiteID parameter was referencing a non-existent 'check_suite_id'
column in the action_run table. This commit removes the hallucinated database
schema reference while maintaining API compatibility.

Changes:
- Remove CheckSuiteID field from FindRunOptions struct
- Remove check_suite_id database query condition
- Remove parameter handling logic from shared action handler
- Remove related tests for non-functional feature
- Update Swagger docs to indicate parameter is not supported in Gitea API
- Maintain GitHub API compatibility by keeping parameter documented

The check_suite_id parameter is now silently ignored when provided,
with clear documentation that it's not supported in Gitea.
2025-06-30 10:44:48 -05:00

89 lines
2.6 KiB
Go

// Copyright 2025 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package actions
import (
"testing"
"time"
"code.gitea.io/gitea/modules/webhook"
"github.com/stretchr/testify/assert"
"xorm.io/builder"
)
func TestFindRunOptions_ToConds_ExcludePullRequests(t *testing.T) {
// Test when ExcludePullRequests is true
opts := FindRunOptions{
ExcludePullRequests: true,
}
cond := opts.ToConds()
// Convert the condition to SQL for assertion
sql, args, err := builder.ToSQL(cond)
assert.NoError(t, err)
// The condition should contain the trigger_event not equal to pull_request
assert.Contains(t, sql, "`action_run`.trigger_event<>")
assert.Contains(t, args, webhook.HookEventPullRequest)
}
func TestFindRunOptions_ToConds_CreatedDateRange(t *testing.T) {
// Test when CreatedAfter and CreatedBefore are set
startDate := time.Date(2023, 1, 1, 0, 0, 0, 0, time.UTC)
endDate := time.Date(2023, 12, 31, 23, 59, 59, 0, time.UTC)
opts := FindRunOptions{
CreatedAfter: startDate,
CreatedBefore: endDate,
}
cond := opts.ToConds()
// Convert the condition to SQL for assertion
sql, args, err := builder.ToSQL(cond)
assert.NoError(t, err)
// The condition should contain created >= startDate and created <= endDate
assert.Contains(t, sql, "`action_run`.created>=")
assert.Contains(t, sql, "`action_run`.created<=")
assert.Contains(t, args, startDate)
assert.Contains(t, args, endDate)
}
func TestFindRunOptions_ToConds_CreatedAfterOnly(t *testing.T) {
// Test when only CreatedAfter is set
startDate := time.Date(2023, 1, 1, 0, 0, 0, 0, time.UTC)
opts := FindRunOptions{
CreatedAfter: startDate,
}
cond := opts.ToConds()
// Convert the condition to SQL for assertion
sql, args, err := builder.ToSQL(cond)
assert.NoError(t, err)
// The condition should contain created >= startDate
assert.Contains(t, sql, "`action_run`.created>=")
assert.Contains(t, args, startDate)
// But should not contain created <= endDate
assert.NotContains(t, sql, "`action_run`.created<=")
}
func TestFindRunOptions_ToConds_CreatedBeforeOnly(t *testing.T) {
// Test when only CreatedBefore is set
endDate := time.Date(2023, 12, 31, 23, 59, 59, 0, time.UTC)
opts := FindRunOptions{
CreatedBefore: endDate,
}
cond := opts.ToConds()
// Convert the condition to SQL for assertion
sql, args, err := builder.ToSQL(cond)
assert.NoError(t, err)
// The condition should contain created <= endDate
assert.Contains(t, sql, "`action_run`.created<=")
assert.Contains(t, args, endDate)
// But should not contain created >= startDate
assert.NotContains(t, sql, "`action_run`.created>=")
}