github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/module/mempool/stdmap/times_test.go (about)

     1  package stdmap_test
     2  
     3  import (
     4  	"testing"
     5  	"time"
     6  
     7  	"github.com/stretchr/testify/assert"
     8  	"github.com/stretchr/testify/require"
     9  
    10  	"github.com/onflow/flow-go/module/mempool/stdmap"
    11  	"github.com/onflow/flow-go/utils/unittest"
    12  )
    13  
    14  func TestTimesPool(t *testing.T) {
    15  	id := unittest.IdentifierFixture()
    16  	ti := time.Now()
    17  
    18  	pool, err := stdmap.NewTimes(3)
    19  	require.NoError(t, err)
    20  
    21  	t.Run("should be able to add", func(t *testing.T) {
    22  		added := pool.Add(id, ti)
    23  		assert.True(t, added)
    24  	})
    25  
    26  	t.Run("should be able to get", func(t *testing.T) {
    27  		got, exists := pool.ByID(id)
    28  		assert.True(t, exists)
    29  		assert.Equal(t, ti, got)
    30  	})
    31  
    32  	t.Run("should be able to remove", func(t *testing.T) {
    33  		ok := pool.Remove(id)
    34  		assert.True(t, ok)
    35  	})
    36  }