github.com/koko1123/flow-go-1@v0.29.6/module/mempool/stdmap/times_test.go (about)

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