mirror of
				https://codeberg.org/forgejo/forgejo.git
				synced 2025-11-04 08:21:11 +00:00 
			
		
		
		
	So they can conveniently be run all together with: `make 'test-sqlite#TestActions'` Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/9035 Reviewed-by: Gusted <gusted@noreply.codeberg.org> Co-authored-by: Earl Warren <contact@earl-warren.org> Co-committed-by: Earl Warren <contact@earl-warren.org>
		
			
				
	
	
		
			38 lines
		
	
	
	
		
			993 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			38 lines
		
	
	
	
		
			993 B
		
	
	
	
		
			Go
		
	
	
	
	
	
// Copyright 2025 The Forgejo Authors. All rights reserved.
 | 
						|
// SPDX-License-Identifier: MIT
 | 
						|
 | 
						|
package integration
 | 
						|
 | 
						|
import (
 | 
						|
	"fmt"
 | 
						|
	"net/http"
 | 
						|
	"testing"
 | 
						|
 | 
						|
	actions_model "forgejo.org/models/actions"
 | 
						|
	auth_model "forgejo.org/models/auth"
 | 
						|
	"forgejo.org/models/unittest"
 | 
						|
	api "forgejo.org/modules/structs"
 | 
						|
	"forgejo.org/tests"
 | 
						|
 | 
						|
	"github.com/stretchr/testify/assert"
 | 
						|
)
 | 
						|
 | 
						|
func TestActionsAPISearchActionJobs_UserRunner(t *testing.T) {
 | 
						|
	defer tests.PrepareTestEnv(t)()
 | 
						|
 | 
						|
	normalUsername := "user2"
 | 
						|
	session := loginUser(t, normalUsername)
 | 
						|
	token := getTokenForLoggedInUser(t, session, auth_model.AccessTokenScopeWriteUser)
 | 
						|
	job := unittest.AssertExistsAndLoadBean(t, &actions_model.ActionRunJob{ID: 394})
 | 
						|
 | 
						|
	req := NewRequest(t, "GET",
 | 
						|
		fmt.Sprintf("/api/v1/user/actions/runners/jobs?labels=%s", "debian-latest")).
 | 
						|
		AddTokenAuth(token)
 | 
						|
	res := MakeRequest(t, req, http.StatusOK)
 | 
						|
 | 
						|
	var jobs []*api.ActionRunJob
 | 
						|
	DecodeJSON(t, res, &jobs)
 | 
						|
 | 
						|
	assert.Len(t, jobs, 1)
 | 
						|
	assert.Equal(t, job.ID, jobs[0].ID)
 | 
						|
}
 |