* Kill gorp

Gorp is dead. Long live Gorp.

```release-note
NONE
```
Этот коммит содержится в:
Agniva De Sarker
2022-03-15 19:49:19 +05:30
коммит произвёл GitHub
родитель c3ec0a145b
Коммит 4da98cb51a
47 изменённых файлов: 102 добавлений и 5179 удалений

Просмотреть файл

@@ -17,7 +17,6 @@ import (
"github.com/go-sql-driver/mysql"
"github.com/lib/pq"
"github.com/mattermost/gorp"
"github.com/pkg/errors"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
@@ -186,12 +185,12 @@ func TestStoreLicenseRace(t *testing.T) {
}()
go func() {
store.GetReplica()
store.GetReplicaX()
wg.Done()
}()
go func() {
store.GetSearchReplica()
store.GetSearchReplicaX()
wg.Done()
}()
@@ -276,14 +275,14 @@ func TestGetReplica(t *testing.T) {
store.UpdateLicense(&model.License{})
replicas := make(map[*gorp.DbMap]bool)
replicas := make(map[*sqlxDBWrapper]bool)
for i := 0; i < 5; i++ {
replicas[store.GetReplica()] = true
replicas[store.GetReplicaX()] = true
}
searchReplicas := make(map[*gorp.DbMap]bool)
searchReplicas := make(map[*sqlxDBWrapper]bool)
for i := 0; i < 5; i++ {
searchReplicas[store.GetSearchReplica()] = true
searchReplicas[store.GetSearchReplicaX()] = true
}
if testCase.DataSourceReplicaNum > 0 {
@@ -291,13 +290,13 @@ func TestGetReplica(t *testing.T) {
assert.Len(t, replicas, testCase.DataSourceReplicaNum)
for replica := range replicas {
assert.NotSame(t, store.GetMaster(), replica)
assert.NotSame(t, store.GetMasterX(), replica)
}
} else if assert.Len(t, replicas, 1) {
// Otherwise ensure the replicas contains only the master.
for replica := range replicas {
assert.Same(t, store.GetMaster(), replica)
assert.Same(t, store.GetMasterX(), replica)
}
}
@@ -306,7 +305,7 @@ func TestGetReplica(t *testing.T) {
assert.Len(t, searchReplicas, testCase.DataSourceSearchReplicaNum)
for searchReplica := range searchReplicas {
assert.NotSame(t, store.GetMaster(), searchReplica)
assert.NotSame(t, store.GetMasterX(), searchReplica)
for replica := range replicas {
assert.NotSame(t, searchReplica, replica)
}
@@ -319,7 +318,7 @@ func TestGetReplica(t *testing.T) {
} else if testCase.DataSourceReplicaNum == 0 && assert.Len(t, searchReplicas, 1) {
// Otherwise ensure the search replicas contains the master.
for searchReplica := range searchReplicas {
assert.Same(t, store.GetMaster(), searchReplica)
assert.Same(t, store.GetMasterX(), searchReplica)
}
}
})
@@ -344,14 +343,14 @@ func TestGetReplica(t *testing.T) {
storetest.CleanupSqlSettings(settings)
}()
replicas := make(map[*gorp.DbMap]bool)
replicas := make(map[*sqlxDBWrapper]bool)
for i := 0; i < 5; i++ {
replicas[store.GetReplica()] = true
replicas[store.GetReplicaX()] = true
}
searchReplicas := make(map[*gorp.DbMap]bool)
searchReplicas := make(map[*sqlxDBWrapper]bool)
for i := 0; i < 5; i++ {
searchReplicas[store.GetSearchReplica()] = true
searchReplicas[store.GetSearchReplicaX()] = true
}
if testCase.DataSourceReplicaNum > 0 {
@@ -359,13 +358,13 @@ func TestGetReplica(t *testing.T) {
assert.Len(t, replicas, 1)
for replica := range replicas {
assert.Same(t, store.GetMaster(), replica)
assert.Same(t, store.GetMasterX(), replica)
}
} else if assert.Len(t, replicas, 1) {
// Otherwise ensure the replicas contains only the master.
for replica := range replicas {
assert.Same(t, store.GetMaster(), replica)
assert.Same(t, store.GetMasterX(), replica)
}
}
@@ -374,7 +373,7 @@ func TestGetReplica(t *testing.T) {
assert.Len(t, searchReplicas, 1)
for searchReplica := range searchReplicas {
assert.Same(t, store.GetMaster(), searchReplica)
assert.Same(t, store.GetMasterX(), searchReplica)
}
} else if testCase.DataSourceReplicaNum > 0 {
@@ -385,7 +384,7 @@ func TestGetReplica(t *testing.T) {
} else if assert.Len(t, searchReplicas, 1) {
// Otherwise ensure the search replicas contains the master.
for searchReplica := range searchReplicas {
assert.Same(t, store.GetMaster(), searchReplica)
assert.Same(t, store.GetMasterX(), searchReplica)
}
}
})
@@ -755,10 +754,10 @@ func TestExecNoTimeout(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
sqlStore := ss.(*SqlStore)
var query string
timeout := sqlStore.master.QueryTimeout
sqlStore.master.QueryTimeout = 1
timeout := sqlStore.masterX.queryTimeout
sqlStore.masterX.queryTimeout = 1
defer func() {
sqlStore.master.QueryTimeout = timeout
sqlStore.masterX.queryTimeout = timeout
}()
if sqlStore.DriverName() == model.DatabaseDriverMysql {
query = `SELECT SLEEP(2);`