@@ -17,6 +17,8 @@ limitations under the License.
|
||||
package server
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
@@ -72,3 +74,22 @@ func TestUpdateImageMetadata(t *testing.T) {
|
||||
assert.Equal(t, test.expectedRepoDigests, m.RepoDigests)
|
||||
}
|
||||
}
|
||||
|
||||
func TestResources(t *testing.T) {
|
||||
const threads = 10
|
||||
var wg sync.WaitGroup
|
||||
r := newResourceSet()
|
||||
for i := 0; i < threads; i++ {
|
||||
wg.Add(1)
|
||||
go func(ref string) {
|
||||
r.add(ref)
|
||||
wg.Done()
|
||||
}(fmt.Sprintf("sha256:%d", i))
|
||||
}
|
||||
wg.Wait()
|
||||
refs := r.all()
|
||||
for i := 0; i < threads; i++ {
|
||||
_, ok := refs[fmt.Sprintf("sha256:%d", i)]
|
||||
assert.True(t, ok)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user