44package  integration
55
66import  (
7- 	"encoding/json" 
87	"fmt" 
98	"net/http" 
9+ 	"strconv" 
1010	"strings" 
1111	"testing" 
1212
@@ -15,6 +15,7 @@ import (
1515	repo_model "code.gitea.io/gitea/models/repo" 
1616	"code.gitea.io/gitea/models/unittest" 
1717	user_model "code.gitea.io/gitea/models/user" 
18+ 	"code.gitea.io/gitea/modules/json" 
1819	"code.gitea.io/gitea/tests" 
1920
2021	"github.com/stretchr/testify/assert" 
@@ -64,7 +65,7 @@ func TestProjectWorkflowsPage(t *testing.T) {
6465		WorkflowActions : []project_model.WorkflowAction {
6566			{
6667				Type :  project_model .WorkflowActionTypeColumn ,
67- 				Value : fmt . Sprintf ( "%d" ,  column1 .ID ),
68+ 				Value : strconv . FormatInt ( column1 .ID ,  10 ),
6869			},
6970		},
7071		Enabled : true ,
@@ -84,7 +85,7 @@ func TestProjectWorkflowsPage(t *testing.T) {
8485		WorkflowActions : []project_model.WorkflowAction {
8586			{
8687				Type :  project_model .WorkflowActionTypeColumn ,
87- 				Value : fmt . Sprintf ( "%d" ,  column2 .ID ),
88+ 				Value : strconv . FormatInt ( column2 .ID ,  10 ),
8889			},
8990		},
9091		Enabled : false , // Disabled workflow 
@@ -101,20 +102,20 @@ func TestProjectWorkflowsPage(t *testing.T) {
101102	htmlDoc  :=  NewHTMLParser (t , resp .Body )
102103
103104	// Verify the main workflow container exists 
104- 	assert .True (t , htmlDoc .Find ("#project-workflows" ).Length ()  >   0 , "Main workflow container should exist" )
105+ 	assert .Positive (t , htmlDoc .Find ("#project-workflows" ).Length (), "Main workflow container should exist" )
105106
106107	// Verify data attributes are set correctly 
107108	workflowDiv  :=  htmlDoc .Find ("#project-workflows" )
108- 	assert .True (t , workflowDiv .Length ()  >   0 , "Workflow div should exist" )
109+ 	assert .Positive (t , workflowDiv .Length (), "Workflow div should exist" )
109110
110111	// Check that locale data attributes exist 
111- 	assert .True (t , workflowDiv .AttrOr ("data-locale-default-workflows" , "" )  !=   "" , "data-locale-default-workflows should be set" )
112- 	assert .True (t , workflowDiv .AttrOr ("data-locale-when" , "" )  !=   "" , "data-locale-when should be set" )
113- 	assert .True (t , workflowDiv .AttrOr ("data-locale-actions" , "" )  !=   "" , "data-locale-actions should be set" )
114- 	assert .True (t , workflowDiv .AttrOr ("data-locale-filters" , "" )  !=   "" , "data-locale-filters should be set" )
115- 	assert .True (t , workflowDiv .AttrOr ("data-locale-close-issue" , "" )  !=   "" , "data-locale-close-issue should be set" )
116- 	assert .True (t , workflowDiv .AttrOr ("data-locale-reopen-issue" , "" )  !=   "" , "data-locale-reopen-issue should be set" )
117- 	assert .True (t , workflowDiv .AttrOr ("data-locale-issues-and-pull-requests" , "" )  !=   "" , "data-locale-issues-and-pull-requests should be set" )
112+ 	assert .NotEmpty (t , workflowDiv .AttrOr ("data-locale-default-workflows" , "" ), "data-locale-default-workflows should be set" )
113+ 	assert .NotEmpty (t , workflowDiv .AttrOr ("data-locale-when" , "" ), "data-locale-when should be set" )
114+ 	assert .NotEmpty (t , workflowDiv .AttrOr ("data-locale-actions" , "" ), "data-locale-actions should be set" )
115+ 	assert .NotEmpty (t , workflowDiv .AttrOr ("data-locale-filters" , "" ), "data-locale-filters should be set" )
116+ 	assert .NotEmpty (t , workflowDiv .AttrOr ("data-locale-close-issue" , "" ), "data-locale-close-issue should be set" )
117+ 	assert .NotEmpty (t , workflowDiv .AttrOr ("data-locale-reopen-issue" , "" ), "data-locale-reopen-issue should be set" )
118+ 	assert .NotEmpty (t , workflowDiv .AttrOr ("data-locale-issues-and-pull-requests" , "" ), "data-locale-issues-and-pull-requests should be set" )
118119
119120	// Verify project link is set 
120121	projectLink  :=  workflowDiv .AttrOr ("data-project-link" , "" )
@@ -173,7 +174,7 @@ func TestProjectWorkflowCreate(t *testing.T) {
173174			string (project_model .WorkflowFilterTypeIssueType ): "issue" ,
174175		},
175176		"actions" : map [string ]any {
176- 			string (project_model .WorkflowActionTypeColumn ): fmt . Sprintf ( "%d" ,  column .ID ),
177+ 			string (project_model .WorkflowActionTypeColumn ): strconv . FormatInt ( column .ID ,  10 ),
177178		},
178179	}
179180
@@ -237,7 +238,7 @@ func TestProjectWorkflowUpdate(t *testing.T) {
237238		WorkflowActions : []project_model.WorkflowAction {
238239			{
239240				Type :  project_model .WorkflowActionTypeColumn ,
240- 				Value : fmt . Sprintf ( "%d" ,  column .ID ),
241+ 				Value : strconv . FormatInt ( column .ID ,  10 ),
241242			},
242243		},
243244		Enabled : true ,
@@ -249,12 +250,12 @@ func TestProjectWorkflowUpdate(t *testing.T) {
249250
250251	// Update the workflow 
251252	updateData  :=  map [string ]any {
252- 		"event_id" : fmt . Sprintf ( "%d" ,  workflow .ID ),
253+ 		"event_id" : strconv . FormatInt ( workflow .ID ,  10 ),
253254		"filters" : map [string ]any {
254255			string (project_model .WorkflowFilterTypeIssueType ): "pull_request" , // Change to PR 
255256		},
256257		"actions" : map [string ]any {
257- 			string (project_model .WorkflowActionTypeColumn ): fmt . Sprintf ( "%d" ,  column .ID ),
258+ 			string (project_model .WorkflowActionTypeColumn ): strconv . FormatInt ( column .ID ,  10 ),
258259		},
259260	}
260261
@@ -401,7 +402,7 @@ func TestProjectWorkflowDelete(t *testing.T) {
401402	// Verify we cannot delete it again (should fail gracefully) 
402403	req  =  NewRequest (t , "POST" ,
403404		fmt .Sprintf ("/%s/%s/projects/%d/workflows/%d/delete?_csrf=%s" , user .Name , repo .Name , project .ID , workflow .ID , GetUserCSRFToken (t , session )))
404- 	resp   =   session .MakeRequest (t , req , http .StatusNotFound )
405+ 	session .MakeRequest (t , req , http .StatusNotFound )
405406}
406407
407408func  TestProjectWorkflowPermissions (t  * testing.T ) {
0 commit comments