storj/satellite/satellitedb/consoledb_test.go

50 lines
1.1 KiB
Go
Raw Normal View History

2019-01-24 16:26:36 +00:00
// Copyright (C) 2019 Storj Labs, Inc.
// See LICENSE for copying information.
2019-01-31 13:01:13 +00:00
package satellitedb_test
import (
"testing"
"github.com/stretchr/testify/assert"
"storj.io/storj/internal/testcontext"
2019-01-31 13:01:13 +00:00
"storj.io/storj/satellite"
"storj.io/storj/satellite/satellitedb/satellitedbtest"
)
2019-01-31 13:01:13 +00:00
func TestConsoleTx(t *testing.T) {
satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) {
ctx := testcontext.New(t)
defer ctx.Cleanup()
2019-01-31 13:01:13 +00:00
console := db.Console()
2019-01-31 13:01:13 +00:00
t.Run("BeginTx, Commit, Rollback", func(t *testing.T) {
tx, err := console.BeginTx(ctx)
assert.NoError(t, err)
assert.NotNil(t, tx)
2019-01-31 13:01:13 +00:00
// TODO: add something into database
2019-01-31 13:01:13 +00:00
assert.NoError(t, tx.Commit())
assert.Error(t, tx.Rollback())
2019-01-31 13:01:13 +00:00
// TODO: check whether it has been committed
})
2019-01-31 13:01:13 +00:00
t.Run("BeginTx, Rollback, Commit", func(t *testing.T) {
tx, err := console.BeginTx(ctx)
assert.NoError(t, err)
assert.NotNil(t, tx)
2019-01-31 13:01:13 +00:00
// TODO: add something into database
2019-01-31 13:01:13 +00:00
assert.NoError(t, tx.Rollback())
assert.Error(t, tx.Commit())
2019-01-31 13:01:13 +00:00
// TODO: check whether it has been rolled back
})
})
}