* fixed: `identifier` is unused lint error

* make saveMultipleMembersT method saveMultipleMembers

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
Mahmudul Haque
2021-02-04 11:38:05 +06:00
коммит произвёл GitHub
родитель 78ccf8a775
Коммит a63dea6c55
62 изменённых файлов: 257 добавлений и 245 удалений

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

@@ -36,7 +36,7 @@ func cleanupChannels(t *testing.T, ss store.Store) {
}
func TestChannelStore(t *testing.T, ss store.Store, s SqlStore) {
createDefaultRoles(t, ss)
createDefaultRoles(ss)
t.Run("Save", func(t *testing.T) { testChannelStoreSave(t, ss) })
t.Run("SaveDirectChannel", func(t *testing.T) { testChannelStoreSaveDirectChannel(t, ss, s) })
@@ -79,7 +79,7 @@ func TestChannelStore(t *testing.T, ss store.Store, s SqlStore) {
t.Run("GetMemberCountsByGroup", func(t *testing.T) { testGetMemberCountsByGroup(t, ss) })
t.Run("GetGuestCount", func(t *testing.T) { testGetGuestCount(t, ss) })
t.Run("SearchMore", func(t *testing.T) { testChannelStoreSearchMore(t, ss) })
t.Run("SearchInTeam", func(t *testing.T) { testChannelStoreSearchInTeam(t, ss, s) })
t.Run("SearchInTeam", func(t *testing.T) { testChannelStoreSearchInTeam(t, ss) })
t.Run("SearchArchivedInTeam", func(t *testing.T) { testChannelStoreSearchArchivedInTeam(t, ss, s) })
t.Run("SearchForUserInTeam", func(t *testing.T) { testChannelStoreSearchForUserInTeam(t, ss) })
t.Run("SearchAllChannels", func(t *testing.T) { testChannelStoreSearchAllChannels(t, ss) })
@@ -107,7 +107,7 @@ func TestChannelStore(t *testing.T, ss store.Store, s SqlStore) {
t.Run("CreateSidebarCategory", func(t *testing.T) { testCreateSidebarCategory(t, ss) })
t.Run("GetSidebarCategory", func(t *testing.T) { testGetSidebarCategory(t, ss, s) })
t.Run("GetSidebarCategories", func(t *testing.T) { testGetSidebarCategories(t, ss) })
t.Run("UpdateSidebarCategories", func(t *testing.T) { testUpdateSidebarCategories(t, ss, s) })
t.Run("UpdateSidebarCategories", func(t *testing.T) { testUpdateSidebarCategories(t, ss) })
t.Run("DeleteSidebarCategory", func(t *testing.T) { testDeleteSidebarCategory(t, ss, s) })
t.Run("UpdateSidebarChannelsByPreferences", func(t *testing.T) { testUpdateSidebarChannelsByPreferences(t, ss) })
}
@@ -4971,7 +4971,7 @@ func testChannelStoreSearchArchivedInTeam(t *testing.T, ss store.Store, s SqlSto
})
}
func testChannelStoreSearchInTeam(t *testing.T, ss store.Store, s SqlStore) {
func testChannelStoreSearchInTeam(t *testing.T, ss store.Store) {
teamId := model.NewId()
otherTeamId := model.NewId()

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

@@ -21,8 +21,9 @@ func TestChannelStoreCategories(t *testing.T, ss store.Store, s SqlStore) {
t.Run("CreateSidebarCategory", func(t *testing.T) { testCreateSidebarCategory(t, ss) })
t.Run("GetSidebarCategory", func(t *testing.T) { testGetSidebarCategory(t, ss, s) })
t.Run("GetSidebarCategories", func(t *testing.T) { testGetSidebarCategories(t, ss) })
t.Run("UpdateSidebarCategories", func(t *testing.T) { testUpdateSidebarCategories(t, ss, s) })
t.Run("UpdateSidebarCategories", func(t *testing.T) { testUpdateSidebarCategories(t, ss) })
t.Run("ClearSidebarOnTeamLeave", func(t *testing.T) { testClearSidebarOnTeamLeave(t, ss, s) })
t.Run("UpdateSidebarCategories", func(t *testing.T) { testUpdateSidebarCategories(t, ss) })
t.Run("DeleteSidebarCategory", func(t *testing.T) { testDeleteSidebarCategory(t, ss, s) })
t.Run("UpdateSidebarChannelsByPreferences", func(t *testing.T) { testUpdateSidebarChannelsByPreferences(t, ss) })
}
@@ -869,7 +870,7 @@ func testGetSidebarCategories(t *testing.T, ss store.Store) {
})
}
func testUpdateSidebarCategories(t *testing.T, ss store.Store, s SqlStore) {
func testUpdateSidebarCategories(t *testing.T, ss store.Store) {
t.Run("ensure the query to update SidebarCategories hasn't been polluted by UpdateSidebarCategoryOrder", func(t *testing.T) {
userId := model.NewId()
teamId := model.NewId()

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

@@ -15,10 +15,10 @@ import (
)
func TestPluginStore(t *testing.T, ss store.Store, s SqlStore) {
t.Run("SaveOrUpdate", func(t *testing.T) { testPluginSaveOrUpdate(t, ss, s) })
t.Run("CompareAndSet", func(t *testing.T) { testPluginCompareAndSet(t, ss, s) })
t.Run("CompareAndDelete", func(t *testing.T) { testPluginCompareAndDelete(t, ss, s) })
t.Run("SetWithOptions", func(t *testing.T) { testPluginSetWithOptions(t, ss, s) })
t.Run("SaveOrUpdate", func(t *testing.T) { testPluginSaveOrUpdate(t, ss) })
t.Run("CompareAndSet", func(t *testing.T) { testPluginCompareAndSet(t, ss) })
t.Run("CompareAndDelete", func(t *testing.T) { testPluginCompareAndDelete(t, ss) })
t.Run("SetWithOptions", func(t *testing.T) { testPluginSetWithOptions(t, ss) })
t.Run("Get", func(t *testing.T) { testPluginGet(t, ss) })
t.Run("Delete", func(t *testing.T) { testPluginDelete(t, ss) })
t.Run("DeleteAllForPlugin", func(t *testing.T) { testPluginDeleteAllForPlugin(t, ss) })
@@ -63,7 +63,7 @@ func setupKVs(t *testing.T, ss store.Store) (string, func()) {
}
}
func doTestPluginSaveOrUpdate(t *testing.T, ss store.Store, s SqlStore, doer func(kv *model.PluginKeyValue) (*model.PluginKeyValue, error)) {
func doTestPluginSaveOrUpdate(t *testing.T, ss store.Store, doer func(kv *model.PluginKeyValue) (*model.PluginKeyValue, error)) {
t.Run("invalid kv", func(t *testing.T) {
_, tearDown := setupKVs(t, ss)
defer tearDown()
@@ -219,15 +219,15 @@ func doTestPluginSaveOrUpdate(t *testing.T, ss store.Store, s SqlStore, doer fun
})
}
func testPluginSaveOrUpdate(t *testing.T, ss store.Store, s SqlStore) {
doTestPluginSaveOrUpdate(t, ss, s, func(kv *model.PluginKeyValue) (*model.PluginKeyValue, error) {
func testPluginSaveOrUpdate(t *testing.T, ss store.Store) {
doTestPluginSaveOrUpdate(t, ss, func(kv *model.PluginKeyValue) (*model.PluginKeyValue, error) {
return ss.Plugin().SaveOrUpdate(kv)
})
}
// doTestPluginCompareAndSet exercises the CompareAndSet functionality, but abstracts the actual
// call to same to allow reuse with SetWithOptions
func doTestPluginCompareAndSet(t *testing.T, ss store.Store, s SqlStore, compareAndSet func(kv *model.PluginKeyValue, oldValue []byte) (bool, error)) {
func doTestPluginCompareAndSet(t *testing.T, ss store.Store, compareAndSet func(kv *model.PluginKeyValue, oldValue []byte) (bool, error)) {
t.Run("invalid kv", func(t *testing.T) {
_, tearDown := setupKVs(t, ss)
defer tearDown()
@@ -419,7 +419,7 @@ func doTestPluginCompareAndSet(t *testing.T, ss store.Store, s SqlStore, compare
}
for description, setToSameValue := range testCases {
makeKV := func(t *testing.T, existingKV *model.PluginKeyValue) *model.PluginKeyValue {
makeKV := func(existingKV *model.PluginKeyValue) *model.PluginKeyValue {
kv := &model.PluginKeyValue{
PluginId: existingKV.PluginId,
Key: existingKV.Key,
@@ -446,7 +446,7 @@ func doTestPluginCompareAndSet(t *testing.T, ss store.Store, s SqlStore, compare
existingKV, tearDown := setup(t)
defer tearDown()
kv := makeKV(t, existingKV)
kv := makeKV(existingKV)
assertUnchanged(t, kv, existingKV, oldValue)
})
}
@@ -456,7 +456,7 @@ func doTestPluginCompareAndSet(t *testing.T, ss store.Store, s SqlStore, compare
existingKV, tearDown := setup(t)
defer tearDown()
kv := makeKV(t, existingKV)
kv := makeKV(existingKV)
assertChanged(t, kv, existingKV.Value)
})
@@ -465,7 +465,7 @@ func doTestPluginCompareAndSet(t *testing.T, ss store.Store, s SqlStore, compare
existingKV, tearDown := setup(t)
defer tearDown()
kv := makeKV(t, existingKV)
kv := makeKV(existingKV)
kv.ExpireAt = model.GetMillis() + 15*1000
assertChanged(t, kv, existingKV.Value)
@@ -475,7 +475,7 @@ func doTestPluginCompareAndSet(t *testing.T, ss store.Store, s SqlStore, compare
existingKV, tearDown := setup(t)
defer tearDown()
kv := makeKV(t, existingKV)
kv := makeKV(existingKV)
kv.ExpireAt = model.GetMillis() - 15*1000
assertRemoved(t, kv, existingKV.Value)
@@ -484,7 +484,7 @@ func doTestPluginCompareAndSet(t *testing.T, ss store.Store, s SqlStore, compare
}
t.Run("setting a nil value", func(t *testing.T) {
makeKV := func(t *testing.T, existingKV *model.PluginKeyValue) *model.PluginKeyValue {
makeKV := func(existingKV *model.PluginKeyValue) *model.PluginKeyValue {
kv := &model.PluginKeyValue{
PluginId: existingKV.PluginId,
Key: existingKV.Key,
@@ -507,7 +507,7 @@ func doTestPluginCompareAndSet(t *testing.T, ss store.Store, s SqlStore, compare
existingKV, tearDown := setup(t)
defer tearDown()
kv := makeKV(t, existingKV)
kv := makeKV(existingKV)
assertUnchanged(t, kv, existingKV, oldValue)
})
}
@@ -517,20 +517,20 @@ func doTestPluginCompareAndSet(t *testing.T, ss store.Store, s SqlStore, compare
existingKV, tearDown := setup(t)
defer tearDown()
kv := makeKV(t, existingKV)
kv := makeKV(existingKV)
assertRemoved(t, kv, existingKV.Value)
})
})
})
}
func testPluginCompareAndSet(t *testing.T, ss store.Store, s SqlStore) {
doTestPluginCompareAndSet(t, ss, s, func(kv *model.PluginKeyValue, oldValue []byte) (bool, error) {
func testPluginCompareAndSet(t *testing.T, ss store.Store) {
doTestPluginCompareAndSet(t, ss, func(kv *model.PluginKeyValue, oldValue []byte) (bool, error) {
return ss.Plugin().CompareAndSet(kv, oldValue)
})
}
func testPluginCompareAndDelete(t *testing.T, ss store.Store, s SqlStore) {
func testPluginCompareAndDelete(t *testing.T, ss store.Store) {
t.Run("invalid kv", func(t *testing.T) {
_, tearDown := setupKVs(t, ss)
defer tearDown()
@@ -660,7 +660,7 @@ func testPluginCompareAndDelete(t *testing.T, ss store.Store, s SqlStore) {
})
}
func testPluginSetWithOptions(t *testing.T, ss store.Store, s SqlStore) {
func testPluginSetWithOptions(t *testing.T, ss store.Store) {
t.Run("invalid options", func(t *testing.T) {
_, tearDown := setupKVs(t, ss)
defer tearDown()
@@ -699,7 +699,7 @@ func testPluginSetWithOptions(t *testing.T, ss store.Store, s SqlStore) {
})
t.Run("atomic", func(t *testing.T) {
doTestPluginCompareAndSet(t, ss, s, func(kv *model.PluginKeyValue, oldValue []byte) (bool, error) {
doTestPluginCompareAndSet(t, ss, func(kv *model.PluginKeyValue, oldValue []byte) (bool, error) {
now := model.GetMillis()
options := model.PluginKVSetOptions{
Atomic: true,
@@ -715,7 +715,7 @@ func testPluginSetWithOptions(t *testing.T, ss store.Store, s SqlStore) {
})
t.Run("non-atomic", func(t *testing.T) {
doTestPluginSaveOrUpdate(t, ss, s, func(kv *model.PluginKeyValue) (*model.PluginKeyValue, error) {
doTestPluginSaveOrUpdate(t, ss, func(kv *model.PluginKeyValue) (*model.PluginKeyValue, error) {
now := model.GetMillis()
options := model.PluginKVSetOptions{
Atomic: false,

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

@@ -361,7 +361,7 @@ func testRoleStorePermanentDeleteAll(t *testing.T, ss store.Store) {
}
func testRoleStoreLowerScopedChannelSchemeRoles(t *testing.T, ss store.Store) {
createDefaultRoles(t, ss)
createDefaultRoles(ss)
teamScheme1 := &model.Scheme{
DisplayName: model.NewId(),

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

@@ -14,7 +14,7 @@ import (
)
func TestSchemeStore(t *testing.T, ss store.Store) {
createDefaultRoles(t, ss)
createDefaultRoles(ss)
t.Run("Save", func(t *testing.T) { testSchemeStoreSave(t, ss) })
t.Run("Get", func(t *testing.T) { testSchemeStoreGet(t, ss) })
@@ -26,7 +26,7 @@ func TestSchemeStore(t *testing.T, ss store.Store) {
t.Run("CountWithoutPermission", func(t *testing.T) { testCountWithoutPermission(t, ss) })
}
func createDefaultRoles(t *testing.T, ss store.Store) {
func createDefaultRoles(ss store.Store) {
ss.Role().Save(&model.Role{
Name: model.TEAM_ADMIN_ROLE_ID,
DisplayName: model.TEAM_ADMIN_ROLE_ID,

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

@@ -26,7 +26,7 @@ func cleanupTeamStore(t *testing.T, ss store.Store) {
}
func TestTeamStore(t *testing.T, ss store.Store) {
createDefaultRoles(t, ss)
createDefaultRoles(ss)
t.Run("Save", func(t *testing.T) { testTeamStoreSave(t, ss) })
t.Run("Update", func(t *testing.T) { testTeamStoreUpdate(t, ss) })