@@ -10,28 +10,41 @@ import (
1010 "testing"
1111
1212 actions_model "code.gitea.io/gitea/models/actions"
13+ auth_model "code.gitea.io/gitea/models/auth"
14+ "code.gitea.io/gitea/models/db"
1315 "code.gitea.io/gitea/models/unittest"
1416 api "code.gitea.io/gitea/modules/structs"
1517 "code.gitea.io/gitea/tests"
1618
1719 "github.com/stretchr/testify/assert"
20+ "github.com/stretchr/testify/require"
1821)
1922
2023func TestAPIUpdateRunnerCapacity (t * testing.T ) {
2124 defer tests .PrepareTestEnv (t )()
2225
26+ ctx := context .Background ()
27+
28+ // Clean up existing runners
29+ require .NoError (t , db .DeleteAllRecords ("action_runner" ))
30+
2331 // Create a test runner
2432 runner := & actions_model.ActionRunner {
25- UUID : "test-capacity-runner" ,
26- Name : "Test Capacity Runner" ,
27- OwnerID : 0 ,
28- RepoID : 0 ,
29- Capacity : 1 ,
33+ UUID : "test-capacity-runner" ,
34+ Name : "Test Capacity Runner" ,
35+ OwnerID : 0 ,
36+ RepoID : 0 ,
37+ Capacity : 1 ,
38+ TokenHash : "test-capacity-hash" ,
39+ Token : "test-capacity-token" ,
3040 }
31- unittest .AssertExistsAndLoadBean (t , runner )
41+ require .NoError (t , actions_model .CreateRunner (ctx , runner ))
42+
43+ // Load the created runner to get the ID
44+ runner = unittest .AssertExistsAndLoadBean (t , & actions_model.ActionRunner {UUID : "test-capacity-runner" })
3245
3346 session := loginUser (t , "user1" )
34- token := getTokenForLoggedInUser (t , session )
47+ token := getTokenForLoggedInUser (t , session , auth_model . AccessTokenScopeWriteAdmin )
3548
3649 t .Run ("UpdateCapacity" , func (t * testing.T ) {
3750 req := NewRequestWithJSON (t , "PATCH" ,
0 commit comments