Drop the legacy `X` suffix from `GetMasterX` and `GetReplicaX`. The
presence of the suffix suggests there's a `non-X` version: but in fact
we migrated these away a long time ago, so remove the cognitive
overhead.

As an aside, this additionally helps avoid trip up LLMs that interpret
this as "something to fix".
Этот коммит содержится в:
Jesse Hallam
2024-12-10 09:57:19 -04:00
коммит произвёл GitHub
родитель 8b86e1276e
Коммит 5369f8b36b
77 изменённых файлов: 892 добавлений и 892 удалений

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

@@ -79,7 +79,7 @@ func testBotStoreGet(t *testing.T, rctx request.CTX, ss store.Store, s SqlStore)
defer func() { require.NoError(t, ss.User().PermanentDelete(rctx, b2.UserId)) }()
// Artificially set b2.LastIconUpdate to NULL to verify handling of same.
_, sqlErr := s.GetMasterX().Exec("UPDATE Bots SET LastIconUpdate = NULL WHERE UserId = '" + b2.UserId + "'")
_, sqlErr := s.GetMaster().Exec("UPDATE Bots SET LastIconUpdate = NULL WHERE UserId = '" + b2.UserId + "'")
require.NoError(t, sqlErr)
t.Run("get non-existent bot", func(t *testing.T) {
@@ -167,7 +167,7 @@ func testBotStoreGetAll(t *testing.T, rctx request.CTX, ss store.Store, s SqlSto
defer func() { require.NoError(t, ss.User().PermanentDelete(rctx, b2.UserId)) }()
// Artificially set b2.LastIconUpdate to NULL to verify handling of same.
_, sqlErr := s.GetMasterX().Exec("UPDATE Bots SET LastIconUpdate = NULL WHERE UserId = '" + b2.UserId + "'")
_, sqlErr := s.GetMaster().Exec("UPDATE Bots SET LastIconUpdate = NULL WHERE UserId = '" + b2.UserId + "'")
require.NoError(t, sqlErr)
t.Run("get original bots", func(t *testing.T) {

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

@@ -27,7 +27,7 @@ import (
)
type SqlStore interface {
GetMasterX() SqlXExecutor
GetMaster() SqlXExecutor
DriverName() string
}
@@ -293,7 +293,7 @@ func testChannelStoreSaveDirectChannel(t *testing.T, rctx request.CTX, ss store.
require.ElementsMatch(t, []string{u1.Id}, userIDs)
// Manually truncate Channels table until testlib can handle cleanups
s.GetMasterX().Exec("TRUNCATE Channels")
s.GetMaster().Exec("TRUNCATE Channels")
}
func testChannelStoreCreateDirectChannel(t *testing.T, rctx request.CTX, ss store.Store) {
@@ -493,7 +493,7 @@ func testChannelStoreGet(t *testing.T, rctx request.CTX, ss store.Store, s SqlSt
require.True(t, errors.As(err, &nfErr))
// Manually truncate Channels table until testlib can handle cleanups
s.GetMasterX().Exec("TRUNCATE Channels")
s.GetMaster().Exec("TRUNCATE Channels")
}
func testChannelStoreGetMany(t *testing.T, rctx request.CTX, ss store.Store, s SqlStore) {
@@ -527,7 +527,7 @@ func testChannelStoreGetMany(t *testing.T, rctx request.CTX, ss store.Store, s S
require.True(t, errors.As(err, &nfErr))
// Manually truncate Channels table until testlib can handle cleanups
s.GetMasterX().Exec("TRUNCATE Channels")
s.GetMaster().Exec("TRUNCATE Channels")
}
func testChannelStoreGetChannelsByIds(t *testing.T, rctx request.CTX, ss store.Store) {
@@ -4006,7 +4006,7 @@ func testChannelStoreGetAllChannels(t *testing.T, rctx request.CTX, ss store.Sto
assert.Equal(t, *list[0].PolicyID, policy.ID)
// Manually truncate Channels table until testlib can handle cleanups
s.GetMasterX().Exec("TRUNCATE Channels")
s.GetMaster().Exec("TRUNCATE Channels")
}
func testChannelStoreGetMoreChannels(t *testing.T, rctx request.CTX, ss store.Store) {
@@ -5774,8 +5774,8 @@ func testChannelStoreSearchArchivedInTeam(t *testing.T, rctx request.CTX, ss sto
t.Run("error", func(t *testing.T) {
// trigger a SQL error
s.GetMasterX().Exec("ALTER TABLE Channels RENAME TO Channels_renamed")
defer s.GetMasterX().Exec("ALTER TABLE Channels_renamed RENAME TO Channels")
s.GetMaster().Exec("ALTER TABLE Channels RENAME TO Channels_renamed")
defer s.GetMaster().Exec("ALTER TABLE Channels_renamed RENAME TO Channels")
list, err := ss.Channel().SearchArchivedInTeam(teamID, "term", userID)
require.Error(t, err)
@@ -6219,7 +6219,7 @@ func testAutocomplete(t *testing.T, rctx request.CTX, ss store.Store, s SqlStore
})
// Manually truncate Channels table until testlib can handle cleanups
s.GetMasterX().Exec("TRUNCATE Channels")
s.GetMaster().Exec("TRUNCATE Channels")
}
func testChannelStoreSearchForUserInTeam(t *testing.T, rctx request.CTX, ss store.Store) {
@@ -7484,7 +7484,7 @@ func testMaterializedPublicChannels(t *testing.T, rctx request.CTX, ss store.Sto
Type: model.ChannelTypeOpen,
}
_, execerr := s.GetMasterX().NamedExec(`
_, execerr := s.GetMaster().NamedExec(`
INSERT INTO
PublicChannels(Id, DeleteAt, TeamId, DisplayName, Name, Header, Purpose)
VALUES
@@ -7502,7 +7502,7 @@ func testMaterializedPublicChannels(t *testing.T, rctx request.CTX, ss store.Sto
o3.DisplayName = "Open Channel 3 - Modified"
_, execerr = s.GetMasterX().NamedExec(`
_, execerr = s.GetMaster().NamedExec(`
INSERT INTO
Channels(Id, CreateAt, UpdateAt, DeleteAt, TeamId, Type, DisplayName, Name, Header, Purpose, LastPostAt, LastRootPostAt, TotalMsgCount, ExtraUpdateAt, CreatorId, TotalMsgCountRoot)
VALUES
@@ -7543,7 +7543,7 @@ func testMaterializedPublicChannels(t *testing.T, rctx request.CTX, ss store.Sto
_, nErr = ss.Channel().Save(rctx, &o4, -1)
require.NoError(t, nErr)
_, execerr = s.GetMasterX().Exec(`
_, execerr = s.GetMaster().Exec(`
DELETE FROM
PublicChannels
WHERE
@@ -7738,7 +7738,7 @@ func testChannelStoreRemoveAllDeactivatedMembers(t *testing.T, rctx request.CTX,
require.ElementsMatch(t, []string{u3.Id}, userIDs)
// Manually truncate Channels table until testlib can handle cleanups
s.GetMasterX().Exec("TRUNCATE Channels")
s.GetMaster().Exec("TRUNCATE Channels")
}
func testChannelStoreExportAllDirectChannels(t *testing.T, rctx request.CTX, ss store.Store, s SqlStore) {
@@ -7795,7 +7795,7 @@ func testChannelStoreExportAllDirectChannels(t *testing.T, rctx request.CTX, ss
assert.ElementsMatch(t, []string{o1.DisplayName, o2.DisplayName}, []string{d1[0].DisplayName, d1[1].DisplayName})
// Manually truncate Channels table until testlib can handle cleanups
s.GetMasterX().Exec("TRUNCATE Channels")
s.GetMaster().Exec("TRUNCATE Channels")
}
func testChannelStoreExportAllDirectChannelsExcludePrivateAndPublic(t *testing.T, rctx request.CTX, ss store.Store, s SqlStore) {
@@ -7857,7 +7857,7 @@ func testChannelStoreExportAllDirectChannelsExcludePrivateAndPublic(t *testing.T
assert.Equal(t, o1.DisplayName, d1[0].DisplayName)
// Manually truncate Channels table until testlib can handle cleanups
s.GetMasterX().Exec("TRUNCATE Channels")
s.GetMaster().Exec("TRUNCATE Channels")
}
func testChannelStoreExportAllDirectChannelsDeletedChannel(t *testing.T, rctx request.CTX, ss store.Store, s SqlStore) {
@@ -7912,7 +7912,7 @@ func testChannelStoreExportAllDirectChannelsDeletedChannel(t *testing.T, rctx re
assert.Len(t, d1[0].Members, 2)
// Manually truncate Channels table until testlib can handle cleanups
s.GetMasterX().Exec("TRUNCATE Channels")
s.GetMaster().Exec("TRUNCATE Channels")
}
func testChannelStoreGetChannelsBatchForIndexing(t *testing.T, rctx request.CTX, ss store.Store) {

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

@@ -751,7 +751,7 @@ func testGetSidebarCategory(t *testing.T, rctx request.CTX, ss store.Store, s Sq
// Confirm that they're not in the Channels category in the DB
var count int64
countErr := s.GetMasterX().Get(&count, `
countErr := s.GetMaster().Get(&count, `
SELECT
COUNT(*)
FROM
@@ -2021,11 +2021,11 @@ func testClearSidebarOnTeamLeave(t *testing.T, rctx request.CTX, ss store.Store,
// Confirm that we start with the right number of categories and SidebarChannels entries
var count int64
err = s.GetMasterX().Get(&count, "SELECT COUNT(*) FROM SidebarCategories WHERE UserId = ?", userID)
err = s.GetMaster().Get(&count, "SELECT COUNT(*) FROM SidebarCategories WHERE UserId = ?", userID)
require.NoError(t, err)
require.Equal(t, int64(4), count)
err = s.GetMasterX().Get(&count, "SELECT COUNT(*) FROM SidebarChannels WHERE UserId = ?", userID)
err = s.GetMaster().Get(&count, "SELECT COUNT(*) FROM SidebarChannels WHERE UserId = ?", userID)
require.NoError(t, err)
require.Equal(t, int64(2), count)
@@ -2034,11 +2034,11 @@ func testClearSidebarOnTeamLeave(t *testing.T, rctx request.CTX, ss store.Store,
assert.NoError(t, err)
// Confirm that all the categories and SidebarChannel entries have been deleted
err = s.GetMasterX().Get(&count, "SELECT COUNT(*) FROM SidebarCategories WHERE UserId = ?", userID)
err = s.GetMaster().Get(&count, "SELECT COUNT(*) FROM SidebarCategories WHERE UserId = ?", userID)
require.NoError(t, err)
assert.Equal(t, int64(0), count)
err = s.GetMasterX().Get(&count, "SELECT COUNT(*) FROM SidebarChannels WHERE UserId = ?", userID)
err = s.GetMaster().Get(&count, "SELECT COUNT(*) FROM SidebarChannels WHERE UserId = ?", userID)
require.NoError(t, err)
assert.Equal(t, int64(0), count)
})
@@ -2070,11 +2070,11 @@ func testClearSidebarOnTeamLeave(t *testing.T, rctx request.CTX, ss store.Store,
// Confirm that we start with the right number of categories and SidebarChannels entries
var count int64
err = s.GetMasterX().Get(&count, "SELECT COUNT(*) FROM SidebarCategories WHERE UserId = ?", userID)
err = s.GetMaster().Get(&count, "SELECT COUNT(*) FROM SidebarCategories WHERE UserId = ?", userID)
require.NoError(t, err)
require.Equal(t, int64(4), count)
err = s.GetMasterX().Get(&count, "SELECT COUNT(*) FROM SidebarChannels WHERE UserId = ?", userID)
err = s.GetMaster().Get(&count, "SELECT COUNT(*) FROM SidebarChannels WHERE UserId = ?", userID)
require.NoError(t, err)
require.Equal(t, int64(2), count)
@@ -2083,11 +2083,11 @@ func testClearSidebarOnTeamLeave(t *testing.T, rctx request.CTX, ss store.Store,
assert.NoError(t, err)
// Confirm that nothing has been deleted
err = s.GetMasterX().Get(&count, "SELECT COUNT(*) FROM SidebarCategories WHERE UserId = ?", userID)
err = s.GetMaster().Get(&count, "SELECT COUNT(*) FROM SidebarCategories WHERE UserId = ?", userID)
require.NoError(t, err)
assert.Equal(t, int64(4), count)
err = s.GetMasterX().Get(&count, "SELECT COUNT(*) FROM SidebarChannels WHERE UserId = ?", userID)
err = s.GetMaster().Get(&count, "SELECT COUNT(*) FROM SidebarChannels WHERE UserId = ?", userID)
require.NoError(t, err)
assert.Equal(t, int64(2), count)
})
@@ -2148,11 +2148,11 @@ func testClearSidebarOnTeamLeave(t *testing.T, rctx request.CTX, ss store.Store,
// Confirm that we start with the right number of categories and SidebarChannels entries
var count int64
err = s.GetMasterX().Get(&count, "SELECT COUNT(*) FROM SidebarCategories WHERE UserId = ?", userID)
err = s.GetMaster().Get(&count, "SELECT COUNT(*) FROM SidebarCategories WHERE UserId = ?", userID)
require.NoError(t, err)
require.Equal(t, int64(8), count)
err = s.GetMasterX().Get(&count, "SELECT COUNT(*) FROM SidebarChannels WHERE UserId = ?", userID)
err = s.GetMaster().Get(&count, "SELECT COUNT(*) FROM SidebarChannels WHERE UserId = ?", userID)
require.NoError(t, err)
require.Equal(t, int64(4), count)
@@ -2161,11 +2161,11 @@ func testClearSidebarOnTeamLeave(t *testing.T, rctx request.CTX, ss store.Store,
assert.NoError(t, err)
// Confirm that we have the correct number of categories and SidebarChannels entries left over
err = s.GetMasterX().Get(&count, "SELECT COUNT(*) FROM SidebarCategories WHERE UserId = ?", userID)
err = s.GetMaster().Get(&count, "SELECT COUNT(*) FROM SidebarCategories WHERE UserId = ?", userID)
require.NoError(t, err)
assert.Equal(t, int64(4), count)
err = s.GetMasterX().Get(&count, "SELECT COUNT(*) FROM SidebarChannels WHERE UserId = ?", userID)
err = s.GetMaster().Get(&count, "SELECT COUNT(*) FROM SidebarChannels WHERE UserId = ?", userID)
require.NoError(t, err)
assert.Equal(t, int64(2), count)
@@ -2259,7 +2259,7 @@ func testDeleteSidebarCategory(t *testing.T, rctx request.CTX, ss store.Store, s
// ...and that the corresponding SidebarChannel entries were deleted
var count int64
countErr := s.GetMasterX().Get(&count, `
countErr := s.GetMaster().Get(&count, `
SELECT
COUNT(*)
FROM

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

@@ -20,7 +20,7 @@ import (
func TestFileInfoStore(t *testing.T, rctx request.CTX, ss store.Store, s SqlStore) {
t.Cleanup(func() {
s.GetMasterX().Exec("TRUNCATE FileInfo")
s.GetMaster().Exec("TRUNCATE FileInfo")
})
t.Run("FileInfoSaveGet", func(t *testing.T) { testFileInfoSaveGet(t, rctx, ss) })
t.Run("FileInfoSaveGetByPath", func(t *testing.T) { testFileInfoSaveGetByPath(t, rctx, ss) })

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

@@ -3279,7 +3279,7 @@ func testPostStoreGetFlaggedPostsForTeam(t *testing.T, rctx request.CTX, ss stor
require.Len(t, r4.Order, 3, "should have 3 posts")
// Manually truncate Channels table until testlib can handle cleanups
s.GetMasterX().Exec("TRUNCATE Channels")
s.GetMaster().Exec("TRUNCATE Channels")
}
func testPostStoreGetFlaggedPosts(t *testing.T, rctx request.CTX, ss store.Store) {
@@ -4550,7 +4550,7 @@ func testPostStoreGetDirectPostParentsForExportAfter(t *testing.T, rctx request.
assert.Equal(t, p1.Message, r1[0].Message)
// Manually truncate Channels table until testlib can handle cleanups
s.GetMasterX().Exec("TRUNCATE Channels")
s.GetMaster().Exec("TRUNCATE Channels")
}
func testPostStoreGetDirectPostParentsForExportAfterDeleted(t *testing.T, rctx request.CTX, ss store.Store, s SqlStore) {
@@ -4613,7 +4613,7 @@ func testPostStoreGetDirectPostParentsForExportAfterDeleted(t *testing.T, rctx r
assert.Equal(t, 1, len(r1))
// Manually truncate Channels table until testlib can handle cleanups
s.GetMasterX().Exec("TRUNCATE Channels")
s.GetMaster().Exec("TRUNCATE Channels")
}
func testPostStoreGetDirectPostParentsForExportAfterBatched(t *testing.T, rctx request.CTX, ss store.Store, s SqlStore) {
@@ -4689,7 +4689,7 @@ func testPostStoreGetDirectPostParentsForExportAfterBatched(t *testing.T, rctx r
assert.ElementsMatch(t, postIds[:100], exportedPostIds)
// Manually truncate Channels table until testlib can handle cleanups
s.GetMasterX().Exec("TRUNCATE Channels")
s.GetMaster().Exec("TRUNCATE Channels")
}
func testHasAutoResponsePostByUserSince(t *testing.T, rctx request.CTX, ss store.Store) {
@@ -4827,7 +4827,7 @@ func testGetPostsSinceUpdateForSync(t *testing.T, rctx request.CTX, ss store.Sto
t.Run("UpdateAt collisions", func(t *testing.T) {
// this test requires all the UpdateAt timestamps to be the same.
result, err := s.GetMasterX().Exec("UPDATE Posts SET UpdateAt = ?", model.GetMillis())
result, err := s.GetMaster().Exec("UPDATE Posts SET UpdateAt = ?", model.GetMillis())
require.NoError(t, err)
rows, err := result.RowsAffected()
require.NoError(t, err)
@@ -4934,7 +4934,7 @@ func testGetPostsSinceCreateForSync(t *testing.T, rctx request.CTX, ss store.Sto
t.Run("CreateAt collisions", func(t *testing.T) {
// this test requires all the CreateAt timestamps to be the same.
result, err := s.GetMasterX().Exec("UPDATE Posts SET CreateAt = ?", model.GetMillis())
result, err := s.GetMaster().Exec("UPDATE Posts SET CreateAt = ?", model.GetMillis())
require.NoError(t, err)
rows, err := result.RowsAffected()
require.NoError(t, err)
@@ -4978,7 +4978,7 @@ func testSetPostReminder(t *testing.T, rctx request.CTX, ss store.Store, s SqlSt
require.NoError(t, ss.Post().SetPostReminder(reminder))
out := model.PostReminder{}
require.NoError(t, s.GetMasterX().Get(&out, `SELECT PostId, UserId, TargetTime FROM PostReminders WHERE PostId=? AND UserId=?`, reminder.PostId, reminder.UserId))
require.NoError(t, s.GetMaster().Get(&out, `SELECT PostId, UserId, TargetTime FROM PostReminders WHERE PostId=? AND UserId=?`, reminder.PostId, reminder.UserId))
assert.Equal(t, reminder, &out)
reminder.PostId = "notfound"
@@ -4994,7 +4994,7 @@ func testSetPostReminder(t *testing.T, rctx request.CTX, ss store.Store, s SqlSt
}
require.NoError(t, ss.Post().SetPostReminder(reminder))
require.NoError(t, s.GetMasterX().Get(&out, `SELECT PostId, UserId, TargetTime FROM PostReminders WHERE PostId=? AND UserId=?`, reminder.PostId, reminder.UserId))
require.NoError(t, s.GetMaster().Get(&out, `SELECT PostId, UserId, TargetTime FROM PostReminders WHERE PostId=? AND UserId=?`, reminder.PostId, reminder.UserId))
assert.Equal(t, reminder, &out)
}

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

@@ -458,7 +458,7 @@ func testDeleteInvalidVisibleDmsGms(t *testing.T, rctx request.CTX, ss store.Sto
}
// Can't insert with Save methods because the values are invalid
_, execerr := s.GetMasterX().NamedExec(`
_, execerr := s.GetMaster().NamedExec(`
INSERT INTO
Preferences(UserId, Category, Name, Value)
VALUES

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

@@ -441,7 +441,7 @@ func forceUpdateAt(reaction *model.Reaction, updateAt int64, s SqlStore) error {
"updateat": updateAt,
}
sqlResult, err := s.GetMasterX().NamedExec(`
sqlResult, err := s.GetMaster().NamedExec(`
UPDATE
Reactions
SET
@@ -468,10 +468,10 @@ func forceUpdateAt(reaction *model.Reaction, updateAt int64, s SqlStore) error {
}
func forceNULL(reaction *model.Reaction, s SqlStore) error {
if _, err := s.GetMasterX().Exec(`UPDATE Reactions SET UpdateAt = NULL WHERE UpdateAt = 0`); err != nil {
if _, err := s.GetMaster().Exec(`UPDATE Reactions SET UpdateAt = NULL WHERE UpdateAt = 0`); err != nil {
return err
}
if _, err := s.GetMasterX().Exec(`UPDATE Reactions SET DeleteAt = NULL WHERE DeleteAt = 0`); err != nil {
if _, err := s.GetMaster().Exec(`UPDATE Reactions SET DeleteAt = NULL WHERE DeleteAt = 0`); err != nil {
return err
}
return nil

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

@@ -151,7 +151,7 @@ func cleanupRetentionPolicyTest(s SqlStore) {
// Manually clear tables until testlib can handle cleanups
tables := []string{"RetentionPolicies", "RetentionPoliciesChannels", "RetentionPoliciesTeams"}
for _, table := range tables {
if _, err := s.GetMasterX().Exec("DELETE FROM " + table); err != nil {
if _, err := s.GetMaster().Exec("DELETE FROM " + table); err != nil {
panic(err)
}
}

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

@@ -581,7 +581,7 @@ func testRoleStoreChannelHigherScopedPermissionsBlankTeamSchemeChannelGuest(t *t
require.NoError(t, err)
// blank-out the guest role to simulate an old team scheme, ensure it's blank
result, sqlErr := s.GetMasterX().Exec(fmt.Sprintf("UPDATE Schemes SET DefaultChannelGuestRole = '' WHERE Id = '%s'", teamScheme.Id))
result, sqlErr := s.GetMaster().Exec(fmt.Sprintf("UPDATE Schemes SET DefaultChannelGuestRole = '' WHERE Id = '%s'", teamScheme.Id))
require.NoError(t, sqlErr)
rows, serr := result.RowsAffected()
require.NoError(t, serr)

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

@@ -654,7 +654,7 @@ func testThreadStorePermanentDeleteBatchThreadMembershipsForRetentionPolicies(t
// Delete team policy and thread
err = ss.RetentionPolicy().Delete(teamPolicy.ID)
require.NoError(t, err)
_, err = s.GetMasterX().Exec("DELETE FROM Threads WHERE PostId='" + post.Id + "'")
_, err = s.GetMaster().Exec("DELETE FROM Threads WHERE PostId='" + post.Id + "'")
require.NoError(t, err)
deleted, err := ss.Thread().DeleteOrphanedRows(1000)

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

@@ -28,7 +28,7 @@ const (
)
func cleanupStatusStore(t *testing.T, s SqlStore) {
_, execerr := s.GetMasterX().Exec(`DELETE FROM Status`)
_, execerr := s.GetMaster().Exec(`DELETE FROM Status`)
require.NoError(t, execerr)
}