github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/storage/badger/procedure/index_test.go (about) 1 package procedure 2 3 import ( 4 "testing" 5 6 "github.com/dgraph-io/badger/v2" 7 "github.com/stretchr/testify/require" 8 9 "github.com/onflow/flow-go/model/flow" 10 "github.com/onflow/flow-go/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 }