Kill gorp (#19786)
* Kill gorp Gorp is dead. Long live Gorp. ```release-note NONE ```
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
c3ec0a145b
Коммит
4da98cb51a
@@ -12,7 +12,6 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/jmoiron/sqlx"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
@@ -80,8 +79,7 @@ func getActualDatabaseConfig(t *testing.T) (string, *model.Config) {
|
||||
ID string `db:"id"`
|
||||
Value []byte `db:"value"`
|
||||
}
|
||||
db := sqlx.NewDb(mainHelper.GetSQLStore().GetMaster().Db, *mainHelper.GetSQLSettings().DriverName)
|
||||
err := db.Get(&actual, "SELECT Id, Value FROM Configurations WHERE Active")
|
||||
err := mainHelper.GetSQLStore().GetMasterX().Get(&actual, "SELECT Id, Value FROM Configurations WHERE Active")
|
||||
require.NoError(t, err)
|
||||
|
||||
var actualCfg *model.Config
|
||||
@@ -93,8 +91,7 @@ func getActualDatabaseConfig(t *testing.T) (string, *model.Config) {
|
||||
ID string `db:"Id"`
|
||||
Value []byte `db:"Value"`
|
||||
}
|
||||
db := sqlx.NewDb(mainHelper.GetSQLStore().GetMaster().Db, *mainHelper.GetSQLSettings().DriverName)
|
||||
err := db.Get(&actual, "SELECT Id, Value FROM Configurations WHERE Active")
|
||||
err := mainHelper.GetSQLStore().GetMasterX().Get(&actual, "SELECT Id, Value FROM Configurations WHERE Active")
|
||||
require.NoError(t, err)
|
||||
|
||||
var actualCfg *model.Config
|
||||
@@ -553,9 +550,7 @@ func TestDatabaseStoreSet(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
defer ds.Close()
|
||||
|
||||
sqlSettings := mainHelper.GetSQLSettings()
|
||||
db := sqlx.NewDb(mainHelper.GetSQLStore().GetMaster().Db, *sqlSettings.DriverName)
|
||||
_, err = db.Exec("DROP TABLE Configurations")
|
||||
_, err = mainHelper.GetSQLStore().GetMasterX().Exec("DROP TABLE Configurations")
|
||||
require.NoError(t, err)
|
||||
|
||||
newCfg := minimalConfig
|
||||
@@ -835,16 +830,15 @@ func TestDatabaseStoreLoad(t *testing.T) {
|
||||
cfgData, err := marshalConfig(invalidConfig)
|
||||
require.NoError(t, err)
|
||||
|
||||
sqlSettings := mainHelper.GetSQLSettings()
|
||||
db := sqlx.NewDb(mainHelper.GetSQLStore().GetMaster().Db, *sqlSettings.DriverName)
|
||||
truncateTables(t)
|
||||
id := model.NewId()
|
||||
_, err = db.NamedExec("INSERT INTO Configurations (Id, Value, CreateAt, Active) VALUES(:Id, :Value, :CreateAt, TRUE)", map[string]interface{}{
|
||||
"Id": id,
|
||||
"Value": cfgData,
|
||||
"CreateAt": model.GetMillis(),
|
||||
_, err = mainHelper.GetSQLStore().GetMasterX().NamedExec("INSERT INTO Configurations (Id, Value, CreateAt, Active) VALUES(:id, :value, :createat, TRUE)", map[string]interface{}{
|
||||
"id": id,
|
||||
"value": cfgData,
|
||||
"createat": model.GetMillis(),
|
||||
})
|
||||
require.NoError(t, err)
|
||||
t.Logf("%v\n", err)
|
||||
require.NoErrorf(t, err, "what is - %v", err)
|
||||
|
||||
err = ds.Load()
|
||||
if assert.Error(t, err) {
|
||||
|
||||
@@ -36,7 +36,7 @@ func truncateTable(t *testing.T, table string) {
|
||||
|
||||
switch *sqlSetting.DriverName {
|
||||
case model.DatabaseDriverMysql:
|
||||
_, err := sqlStore.GetMaster().Db.Exec(fmt.Sprintf("TRUNCATE TABLE %s", table))
|
||||
_, err := sqlStore.GetMasterX().Exec(fmt.Sprintf("TRUNCATE TABLE %s", table))
|
||||
if err != nil {
|
||||
if driverErr, ok := err.(*mysql.MySQLError); ok {
|
||||
// Ignore if the Configurations table does not exist.
|
||||
@@ -48,7 +48,7 @@ func truncateTable(t *testing.T, table string) {
|
||||
require.NoError(t, err)
|
||||
|
||||
case model.DatabaseDriverPostgres:
|
||||
_, err := sqlStore.GetMaster().Db.Exec(fmt.Sprintf("TRUNCATE TABLE %s", table))
|
||||
_, err := sqlStore.GetMasterX().Exec(fmt.Sprintf("TRUNCATE TABLE %s", table))
|
||||
if err != nil {
|
||||
if driverErr, ok := err.(*pq.Error); ok {
|
||||
// Ignore if the Configurations table does not exist.
|
||||
|
||||
Ссылка в новой задаче
Block a user