1
0
mirror of https://github.com/mattermost/focalboard.git synced 2024-12-18 09:35:25 +02:00
focalboard/server/services/store/sqlstore/blocks_test.go

39 lines
751 B
Go

package sqlstore
import (
"testing"
"time"
"github.com/mattermost/mattermost-octo-tasks/server/model"
"github.com/stretchr/testify/require"
)
func TestInsertBlock(t *testing.T) {
store, tearDown := SetupTests(t)
defer tearDown()
blocks, err := store.GetAllBlocks()
require.NoError(t, err)
require.Empty(t, blocks)
block := model.Block{
ID: "id-test",
}
err = store.InsertBlock(block)
require.NoError(t, err)
blocks, err = store.GetAllBlocks()
require.NoError(t, err)
require.Len(t, blocks, 1)
// Wait for not colliding the ID+insert_at key
time.Sleep(1 * time.Millisecond)
err = store.DeleteBlock(block.ID)
require.NoError(t, err)
blocks, err = store.GetAllBlocks()
require.NoError(t, err)
require.Empty(t, blocks)
}