github.com/cilium/cilium@v1.16.2/pkg/policy/groups/cache_test.go (about)

     1  // SPDX-License-Identifier: Apache-2.0
     2  // Copyright Authors of Cilium
     3  
     4  package groups
     5  
     6  import (
     7  	"testing"
     8  
     9  	"github.com/stretchr/testify/require"
    10  )
    11  
    12  func TestCacheWorkingCorrectly(t *testing.T) {
    13  
    14  	cnps := groupsCNPCache.GetAllCNP()
    15  	require.Len(t, cnps, 0)
    16  
    17  	cnp := getSamplePolicy("test", "test")
    18  	groupsCNPCache.UpdateCNP(cnp)
    19  
    20  	cnps = groupsCNPCache.GetAllCNP()
    21  	require.Len(t, cnps, 1)
    22  
    23  	groupsCNPCache.DeleteCNP(cnp)
    24  
    25  	cnps = groupsCNPCache.GetAllCNP()
    26  	require.Len(t, cnps, 0)
    27  
    28  }