github.com/koko1123/flow-go-1@v0.29.6/storage/badger/procedure/index_test.go (about) 1 package procedure 2 3 import ( 4 "testing" 5 6 "github.com/dgraph-io/badger/v3" 7 "github.com/stretchr/testify/require" 8 9 "github.com/koko1123/flow-go-1/model/flow" 10 "github.com/koko1123/flow-go-1/utils/unittest" 11 ) 12 13 func TestInsertRetrieveIndex(t *testing.T) { 14 unittest.RunWithBadgerDB(t, func(db *badger.DB) { 15 blockID := unittest.IdentifierFixture() 16 index := unittest.IndexFixture() 17 18 err := db.Update(InsertIndex(blockID, index)) 19 require.NoError(t, err) 20 21 var retrieved flow.Index 22 err = db.View(RetrieveIndex(blockID, &retrieved)) 23 require.NoError(t, err) 24 25 require.Equal(t, index, &retrieved) 26 }) 27 }