mirror of
https://gitea.com/gitea/runner.git
synced 2026-11-18 13:53:42 +00:00
enhance: make shared tool cache safe at any capacity (#1401)
Co-authored-by: bircni <[email protected]>
This commit is contained in:
1 parent
84c0fcd1fa
commit
a021d3139d
9 files changed
+121
-11
No files matched your search
@@ -0,0 +1,27 @@
|
||||
// Copyright 2026 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package run
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"gitea.com/gitea/runner/internal/pkg/config"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestToolCacheSlotReusesLowestFree(t *testing.T) {
|
||||
var slots slotAllocator
|
||||
require.Equal(t, 0, slots.acquire())
|
||||
require.Equal(t, 1, slots.acquire())
|
||||
require.Equal(t, 2, slots.acquire())
|
||||
slots.release(1)
|
||||
assert.Equal(t, 1, slots.acquire())
|
||||
assert.Equal(t, 3, slots.acquire())
|
||||
|
||||
assert.Equal(t, "3", toolCacheSlot(config.ToolCacheModeShared, 3))
|
||||
assert.Empty(t, toolCacheSlot(config.ToolCacheModeShared, 0))
|
||||
assert.Empty(t, toolCacheSlot(config.ToolCacheModeNone, 3))
|
||||
}
|
||||
Reference in new issue
Block a user