Use require/assert.Empty instead of require/assert.Len(t, X, 0) (#13413)

Этот коммит содержится в:
Jesús Espino
2019-12-22 12:35:31 +01:00
коммит произвёл GitHub
родитель fdd1ae974f
Коммит b3e49ec45c
35 изменённых файлов: 203 добавлений и 202 удалений

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

@@ -703,7 +703,7 @@ func TestGetPublicChannelsForTeam(t *testing.T) {
channels, resp = Client.GetPublicChannelsForTeam(team.Id, 10000, 100, "")
CheckNoError(t, resp)
require.Len(t, channels, 0, "should be no channel")
require.Empty(t, channels, "should be no channel")
_, resp = Client.GetPublicChannelsForTeam("junk", 0, 100, "")
CheckBadRequestStatus(t, resp)
@@ -843,7 +843,7 @@ func TestGetAllChannels(t *testing.T) {
channels, resp = th.SystemAdminClient.GetAllChannels(10000, 10000, "")
CheckNoError(t, resp)
require.Len(t, *channels, 0)
require.Empty(t, *channels)
_, resp = Client.GetAllChannels(0, 20, "")
CheckForbiddenStatus(t, resp)
@@ -874,7 +874,7 @@ func TestGetAllChannelsWithCount(t *testing.T) {
channels, _, resp = th.SystemAdminClient.GetAllChannelsWithCount(10000, 10000, "")
CheckNoError(t, resp)
require.Len(t, *channels, 0)
require.Empty(t, *channels)
_, _, resp = Client.GetAllChannelsWithCount(0, 20, "")
CheckForbiddenStatus(t, resp)
@@ -1155,7 +1155,7 @@ func TestSearchGroupChannels(t *testing.T) {
channels, resp = Client.SearchGroupChannels(search)
CheckNoError(t, resp)
assert.Len(t, channels, 0)
assert.Empty(t, channels)
// search unprivileged, forbidden
th.Client.Logout()
@@ -1575,7 +1575,7 @@ func TestGetChannelMembers(t *testing.T) {
members, resp = Client.GetChannelMembers(th.BasicChannel.Id, 1000, 100000, "")
CheckNoError(t, resp)
require.Len(t, *members, 0, "should be 0 users")
require.Empty(t, *members, "should be 0 users")
_, resp = Client.GetChannelMembers("", 0, 60, "")
CheckBadRequestStatus(t, resp)
@@ -1613,7 +1613,7 @@ func TestGetChannelMembersByIds(t *testing.T) {
cm1, resp := Client.GetChannelMembersByIds(th.BasicChannel.Id, []string{"junk"})
CheckNoError(t, resp)
require.Len(t, *cm1, 0, "no users should be returned")
require.Empty(t, *cm1, "no users should be returned")
cm1, resp = Client.GetChannelMembersByIds(th.BasicChannel.Id, []string{"junk", th.BasicUser.Id})
CheckNoError(t, resp)
@@ -1874,7 +1874,7 @@ func TestGetPinnedPosts(t *testing.T) {
posts, resp := Client.GetPinnedPosts(channel.Id, "")
CheckNoError(t, resp)
require.Len(t, posts.Posts, 0, "should not have gotten a pinned post")
require.Empty(t, posts.Posts, "should not have gotten a pinned post")
pinnedPost := th.CreatePinnedPost()
posts, resp = Client.GetPinnedPosts(channel.Id, "")
@@ -2875,7 +2875,7 @@ func TestGetChannelMembersTimezones(t *testing.T) {
timezone, resp = Client.GetChannelMembersTimezones(th.BasicChannel.Id)
CheckNoError(t, resp)
require.Len(t, timezone, 0, "should return 0 timezone")
require.Empty(t, timezone, "should return 0 timezone")
}
func TestChannelMembersMinusGroupMembers(t *testing.T) {

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

@@ -387,7 +387,7 @@ func TestDisableOnRemove(t *testing.T) {
// Check initial status
pluginsResp, resp := th.SystemAdminClient.GetPlugins()
CheckNoError(t, resp)
require.Len(t, pluginsResp.Active, 0)
require.Empty(t, pluginsResp.Active)
require.Equal(t, pluginsResp.Inactive, []*model.PluginInfo{{
Manifest: *manifest,
}})
@@ -400,7 +400,7 @@ func TestDisableOnRemove(t *testing.T) {
// Confirm enabled status
pluginsResp, resp = th.SystemAdminClient.GetPlugins()
CheckNoError(t, resp)
require.Len(t, pluginsResp.Inactive, 0)
require.Empty(t, pluginsResp.Inactive)
require.Equal(t, pluginsResp.Active, []*model.PluginInfo{{
Manifest: *manifest,
}})
@@ -414,7 +414,7 @@ func TestDisableOnRemove(t *testing.T) {
// Plugin should remain active
pluginsResp, resp = th.SystemAdminClient.GetPlugins()
CheckNoError(t, resp)
require.Len(t, pluginsResp.Inactive, 0)
require.Empty(t, pluginsResp.Inactive)
require.Equal(t, pluginsResp.Active, []*model.PluginInfo{{
Manifest: *manifest,
}})
@@ -428,8 +428,8 @@ func TestDisableOnRemove(t *testing.T) {
// Plugin should have no status
pluginsResp, resp = th.SystemAdminClient.GetPlugins()
CheckNoError(t, resp)
require.Len(t, pluginsResp.Inactive, 0)
require.Len(t, pluginsResp.Active, 0)
require.Empty(t, pluginsResp.Inactive)
require.Empty(t, pluginsResp.Active)
// Upload same plugin
manifest, resp = th.SystemAdminClient.UploadPlugin(bytes.NewReader(tarData))
@@ -439,7 +439,7 @@ func TestDisableOnRemove(t *testing.T) {
// Plugin should be inactive
pluginsResp, resp = th.SystemAdminClient.GetPlugins()
CheckNoError(t, resp)
require.Len(t, pluginsResp.Active, 0)
require.Empty(t, pluginsResp.Active)
require.Equal(t, pluginsResp.Inactive, []*model.PluginInfo{{
Manifest: *manifest,
}})
@@ -511,7 +511,7 @@ func TestGetMarketplacePlugins(t *testing.T) {
plugins, resp := th.SystemAdminClient.GetMarketplacePlugins(&model.MarketplacePluginFilter{})
CheckNoError(t, resp)
require.Len(t, plugins, 0)
require.Empty(t, plugins)
})
t.Run("verify server version is passed through", func(t *testing.T) {
@@ -536,7 +536,7 @@ func TestGetMarketplacePlugins(t *testing.T) {
plugins, resp := th.SystemAdminClient.GetMarketplacePlugins(&model.MarketplacePluginFilter{})
CheckNoError(t, resp)
require.Len(t, plugins, 0)
require.Empty(t, plugins)
})
}

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

@@ -36,7 +36,7 @@ func TestCreatePost(t *testing.T) {
require.Equal(t, post.Message, rpost.Message, "message didn't match")
require.Equal(t, "#hashtag", rpost.Hashtags, "hashtag didn't match")
require.Len(t, rpost.FileIds, 0, "shouldn't have files")
require.Empty(t, rpost.FileIds)
require.Equal(t, 0, int(rpost.EditAt), "newly created post shouldn't have EditAt set")
require.Nil(t, rpost.Props[model.PROPS_ADD_CHANNEL_MEMBER], "newly created post shouldn't have Props['add_channel_member'] set")
@@ -932,7 +932,7 @@ func TestGetPostsForChannel(t *testing.T) {
posts, resp = Client.GetPostsForChannel(th.BasicChannel.Id, 10000, 10000, "")
CheckNoError(t, resp)
require.Len(t, posts.Order, 0, "should be no posts")
require.Empty(t, posts.Order, "should be no posts")
post5 := th.CreatePost()
@@ -1035,7 +1035,7 @@ func TestGetPostsForChannel(t *testing.T) {
// similar to '/posts?per_page=3&page=4'
posts, resp = Client.GetPostsForChannel(th.BasicChannel.Id, 4, 3, "")
CheckNoError(t, resp)
require.Len(t, posts.Order, 0, "should return 0 post")
require.Empty(t, posts.Order, "should return 0 post")
require.Equal(t, "", posts.NextPostId, "should return an empty NextPostId")
require.Equal(t, "", posts.PrevPostId, "should return an empty PrevPostId")
}
@@ -1079,11 +1079,11 @@ func TestGetFlaggedPostsForUser(t *testing.T) {
rpl, resp = Client.GetFlaggedPostsForUserInChannel(user.Id, channel1.Id, 1, 1)
CheckNoError(t, resp)
require.Len(t, rpl.Posts, 0, "should be empty")
require.Empty(t, rpl.Posts)
rpl, resp = Client.GetFlaggedPostsForUserInChannel(user.Id, GenerateTestId(), 0, 10)
CheckNoError(t, resp)
require.Len(t, rpl.Posts, 0, "should be empty")
require.Empty(t, rpl.Posts)
rpl, resp = Client.GetFlaggedPostsForUserInChannel(user.Id, "junk", 0, 10)
CheckBadRequestStatus(t, resp)
@@ -1107,11 +1107,11 @@ func TestGetFlaggedPostsForUser(t *testing.T) {
rpl, resp = Client.GetFlaggedPostsForUserInTeam(user.Id, team1.Id, 1000, 10)
CheckNoError(t, resp)
require.Len(t, rpl.Posts, 0, "should be empty")
require.Empty(t, rpl.Posts)
rpl, resp = Client.GetFlaggedPostsForUserInTeam(user.Id, GenerateTestId(), 0, 10)
CheckNoError(t, resp)
require.Len(t, rpl.Posts, 0, "should be empty")
require.Empty(t, rpl.Posts)
rpl, resp = Client.GetFlaggedPostsForUserInTeam(user.Id, "junk", 0, 10)
CheckBadRequestStatus(t, resp)
@@ -1141,7 +1141,7 @@ func TestGetFlaggedPostsForUser(t *testing.T) {
rpl, resp = Client.GetFlaggedPostsForUser(user.Id, 1000, 10)
CheckNoError(t, resp)
require.Len(t, rpl.Posts, 0, "should be empty")
require.Empty(t, rpl.Posts)
channel4 := th.CreateChannelWithClient(th.SystemAdminClient, model.CHANNEL_PRIVATE)
post5 := th.CreatePostWithClient(th.SystemAdminClient, channel4)
@@ -1181,7 +1181,7 @@ func TestGetFlaggedPostsForUser(t *testing.T) {
opl2.AddPost(post4)
opl2.AddOrder(post4.Id)
require.Equal(t, 3, len(rpl.Posts), "should have returned 3 posts")
require.Len(t, rpl.Posts, 3, "should have returned 3 posts")
require.Equal(t, opl2.Posts, rpl.Posts, "posts should have matched")
_, resp = Client.GetFlaggedPostsForUser("junk", 0, 10)
@@ -1246,7 +1246,7 @@ func TestGetPostsBefore(t *testing.T) {
posts, resp = Client.GetPostsBefore(th.BasicChannel.Id, post4.Id, 1, 1, "")
CheckNoError(t, resp)
require.Equal(t, 1, len(posts.Posts), "too many posts returned")
require.Len(t, posts.Posts, 1, "too many posts returned")
require.Equal(t, post2.Id, posts.Order[0], "should match returned post")
require.Equal(t, post3.Id, posts.NextPostId, "should match NextPostId")
require.Equal(t, post1.Id, posts.PrevPostId, "should match PrevPostId")
@@ -1256,7 +1256,7 @@ func TestGetPostsBefore(t *testing.T) {
posts, resp = Client.GetPostsBefore(th.BasicChannel.Id, post5.Id, 0, 3, "")
CheckNoError(t, resp)
require.Equal(t, 3, len(posts.Posts), "should match length of posts returned")
require.Len(t, posts.Posts, 3, "should match length of posts returned")
require.Equal(t, post4.Id, posts.Order[0], "should match returned post")
require.Equal(t, post2.Id, posts.Order[2], "should match returned post")
require.Equal(t, post5.Id, posts.NextPostId, "should match NextPostId")
@@ -1270,7 +1270,7 @@ func TestGetPostsBefore(t *testing.T) {
posts, resp = Client.GetPostsBefore(th.BasicChannel.Id, post5.Id, 1, 3, "")
CheckNoError(t, resp)
require.Equal(t, 3, len(posts.Posts), "should match length of posts returned")
require.Len(t, posts.Posts, 3, "should match length of posts returned")
require.Equal(t, post1.Id, posts.Order[0], "should match returned post")
require.Equal(t, systemPostId2, posts.Order[1], "should match returned post")
require.Equal(t, systemPostId1, posts.Order[2], "should match returned post")
@@ -1288,7 +1288,7 @@ func TestGetPostsBefore(t *testing.T) {
// similar to '/posts?before=post9'
posts, resp = Client.GetPostsBefore(th.BasicChannel.Id, post9.Id, 0, 60, "")
CheckNoError(t, resp)
require.Equal(t, 10, len(posts.Order), "expected 10 posts")
require.Len(t, posts.Order, 10, "expected 10 posts")
require.Equal(t, post8.Id, posts.Order[0], "posts not in order")
require.Equal(t, systemPostId1, posts.Order[9], "posts not in order")
require.Equal(t, post9.Id, posts.NextPostId, "should return post9.Id as NextPostId")
@@ -1297,7 +1297,7 @@ func TestGetPostsBefore(t *testing.T) {
// similar to '/posts?before=post9&per_page=3'
posts, resp = Client.GetPostsBefore(th.BasicChannel.Id, post9.Id, 0, 3, "")
CheckNoError(t, resp)
require.Equal(t, 3, len(posts.Order), "expected 3 posts")
require.Len(t, posts.Order, 3, "expected 3 posts")
require.Equal(t, post8.Id, posts.Order[0], "posts not in order")
require.Equal(t, post6.Id, posts.Order[2], "should return 3 posts and match order")
require.Equal(t, post9.Id, posts.NextPostId, "should return post9.Id as NextPostId")
@@ -1306,7 +1306,7 @@ func TestGetPostsBefore(t *testing.T) {
// similar to '/posts?before=post9&per_page=3&page=1'
posts, resp = Client.GetPostsBefore(th.BasicChannel.Id, post9.Id, 1, 3, "")
CheckNoError(t, resp)
require.Equal(t, 3, len(posts.Order), "expected 3 posts")
require.Len(t, posts.Order, 3, "expected 3 posts")
require.Equal(t, post5.Id, posts.Order[0], "posts not in order")
require.Equal(t, post3.Id, posts.Order[2], "posts not in order")
require.Equal(t, post6.Id, posts.NextPostId, "should return post6.Id as NextPostId")
@@ -1315,7 +1315,7 @@ func TestGetPostsBefore(t *testing.T) {
// similar to '/posts?before=post9&per_page=3&page=2'
posts, resp = Client.GetPostsBefore(th.BasicChannel.Id, post9.Id, 2, 3, "")
CheckNoError(t, resp)
require.Equal(t, 3, len(posts.Order), "expected 3 posts")
require.Len(t, posts.Order, 3, "expected 3 posts")
require.Equal(t, post2.Id, posts.Order[0], "posts not in order")
require.Equal(t, systemPostId2, posts.Order[2], "posts not in order")
require.Equal(t, post3.Id, posts.NextPostId, "should return post3.Id as NextPostId")
@@ -1324,7 +1324,7 @@ func TestGetPostsBefore(t *testing.T) {
// similar to '/posts?before=post1&per_page=3'
posts, resp = Client.GetPostsBefore(th.BasicChannel.Id, post1.Id, 0, 3, "")
CheckNoError(t, resp)
require.Equal(t, 2, len(posts.Order), "expected 2 posts")
require.Len(t, posts.Order, 2, "expected 2 posts")
require.Equal(t, systemPostId2, posts.Order[0], "posts not in order")
require.Equal(t, systemPostId1, posts.Order[1], "posts not in order")
require.Equal(t, post1.Id, posts.NextPostId, "should return post1.Id as NextPostId")
@@ -1333,14 +1333,14 @@ func TestGetPostsBefore(t *testing.T) {
// similar to '/posts?before=systemPostId1'
posts, resp = Client.GetPostsBefore(th.BasicChannel.Id, systemPostId1, 0, 60, "")
CheckNoError(t, resp)
require.Equal(t, 0, len(posts.Order), "should return 0 post")
require.Empty(t, posts.Order, "should return 0 post")
require.Equal(t, systemPostId1, posts.NextPostId, "should return systemPostId1 as NextPostId")
require.Equal(t, "", posts.PrevPostId, "should return an empty PrevPostId")
// similar to '/posts?before=systemPostId1&per_page=60&page=1'
posts, resp = Client.GetPostsBefore(th.BasicChannel.Id, systemPostId1, 1, 60, "")
CheckNoError(t, resp)
require.Equal(t, 0, len(posts.Order), "should return 0 posts")
require.Empty(t, posts.Order, "should return 0 posts")
require.Equal(t, "", posts.NextPostId, "should return an empty NextPostId")
require.Equal(t, "", posts.PrevPostId, "should return an empty PrevPostId")
@@ -1348,7 +1348,7 @@ func TestGetPostsBefore(t *testing.T) {
nonExistentPostId := model.NewId()
posts, resp = Client.GetPostsBefore(th.BasicChannel.Id, nonExistentPostId, 0, 60, "")
CheckNoError(t, resp)
require.Equal(t, 0, len(posts.Order), "should return 0 post")
require.Empty(t, posts.Order, "should return 0 post")
require.Equal(t, nonExistentPostId, posts.NextPostId, "should return nonExistentPostId as NextPostId")
require.Equal(t, "", posts.PrevPostId, "should return an empty PrevPostId")
}
@@ -1386,7 +1386,7 @@ func TestGetPostsAfter(t *testing.T) {
posts, resp = Client.GetPostsAfter(th.BasicChannel.Id, post2.Id, 1, 1, "")
CheckNoError(t, resp)
require.Equal(t, 1, len(posts.Posts), "too many posts returned")
require.Len(t, posts.Posts, 1, "too many posts returned")
require.Equal(t, post4.Id, posts.Order[0], "should match returned post")
require.Equal(t, post5.Id, posts.NextPostId, "should match NextPostId")
require.Equal(t, post3.Id, posts.PrevPostId, "should match PrevPostId")
@@ -1396,7 +1396,7 @@ func TestGetPostsAfter(t *testing.T) {
posts, resp = Client.GetPostsAfter(th.BasicChannel.Id, post1.Id, 0, 3, "")
CheckNoError(t, resp)
require.Equal(t, 3, len(posts.Posts), "should match length of posts returned")
require.Len(t, posts.Posts, 3, "should match length of posts returned")
require.Equal(t, post4.Id, posts.Order[0], "should match returned post")
require.Equal(t, post2.Id, posts.Order[2], "should match returned post")
require.Equal(t, post5.Id, posts.NextPostId, "should match NextPostId")
@@ -1404,7 +1404,7 @@ func TestGetPostsAfter(t *testing.T) {
posts, resp = Client.GetPostsAfter(th.BasicChannel.Id, post1.Id, 1, 3, "")
CheckNoError(t, resp)
require.Equal(t, 1, len(posts.Posts), "should match length of posts returned")
require.Len(t, posts.Posts, 1, "should match length of posts returned")
require.Equal(t, post5.Id, posts.Order[0], "should match returned post")
require.Equal(t, "", posts.NextPostId, "should match NextPostId")
require.Equal(t, post4.Id, posts.PrevPostId, "should match PrevPostId")
@@ -1420,7 +1420,7 @@ func TestGetPostsAfter(t *testing.T) {
// similar to '/posts?after=post2'
posts, resp = Client.GetPostsAfter(th.BasicChannel.Id, post2.Id, 0, 60, "")
CheckNoError(t, resp)
require.Equal(t, 8, len(posts.Order), "expected 8 posts")
require.Len(t, posts.Order, 8, "expected 8 posts")
require.Equal(t, post10.Id, posts.Order[0], "should match order")
require.Equal(t, post3.Id, posts.Order[7], "should match order")
require.Equal(t, "", posts.NextPostId, "should return an empty NextPostId")
@@ -1429,7 +1429,7 @@ func TestGetPostsAfter(t *testing.T) {
// similar to '/posts?after=post2&per_page=3'
posts, resp = Client.GetPostsAfter(th.BasicChannel.Id, post2.Id, 0, 3, "")
CheckNoError(t, resp)
require.Equal(t, 3, len(posts.Order), "expected 3 posts")
require.Len(t, posts.Order, 3, "expected 3 posts")
require.Equal(t, post5.Id, posts.Order[0], "should match order")
require.Equal(t, post3.Id, posts.Order[2], "should return 3 posts and match order")
require.Equal(t, post6.Id, posts.NextPostId, "should return post6.Id as NextPostId")
@@ -1438,7 +1438,7 @@ func TestGetPostsAfter(t *testing.T) {
// similar to '/posts?after=post2&per_page=3&page=1'
posts, resp = Client.GetPostsAfter(th.BasicChannel.Id, post2.Id, 1, 3, "")
CheckNoError(t, resp)
require.Equal(t, 3, len(posts.Order), "expected 3 posts")
require.Len(t, posts.Order, 3, "expected 3 posts")
require.Equal(t, post8.Id, posts.Order[0], "should match order")
require.Equal(t, post6.Id, posts.Order[2], "should match order")
require.Equal(t, post9.Id, posts.NextPostId, "should return post9.Id as NextPostId")
@@ -1447,7 +1447,7 @@ func TestGetPostsAfter(t *testing.T) {
// similar to '/posts?after=post2&per_page=3&page=2'
posts, resp = Client.GetPostsAfter(th.BasicChannel.Id, post2.Id, 2, 3, "")
CheckNoError(t, resp)
require.Equal(t, 2, len(posts.Order), "expected 2 posts")
require.Len(t, posts.Order, 2, "expected 2 posts")
require.Equal(t, post10.Id, posts.Order[0], "should match order")
require.Equal(t, post9.Id, posts.Order[1], "should match order")
require.Equal(t, "", posts.NextPostId, "should return an empty NextPostId")
@@ -1456,14 +1456,14 @@ func TestGetPostsAfter(t *testing.T) {
// similar to '/posts?after=post10'
posts, resp = Client.GetPostsAfter(th.BasicChannel.Id, post10.Id, 0, 60, "")
CheckNoError(t, resp)
require.Equal(t, 0, len(posts.Order), "should return 0 post")
require.Empty(t, posts.Order, "should return 0 post")
require.Equal(t, "", posts.NextPostId, "should return an empty NextPostId")
require.Equal(t, post10.Id, posts.PrevPostId, "should return post10.Id as PrevPostId")
// similar to '/posts?after=post10&page=1'
posts, resp = Client.GetPostsAfter(th.BasicChannel.Id, post10.Id, 1, 60, "")
CheckNoError(t, resp)
require.Equal(t, 0, len(posts.Order), "should return 0 post")
require.Empty(t, posts.Order, "should return 0 post")
require.Equal(t, "", posts.NextPostId, "should return an empty NextPostId")
require.Equal(t, "", posts.PrevPostId, "should return an empty PrevPostId")
@@ -1471,7 +1471,7 @@ func TestGetPostsAfter(t *testing.T) {
nonExistentPostId := model.NewId()
posts, resp = Client.GetPostsAfter(th.BasicChannel.Id, nonExistentPostId, 0, 60, "")
CheckNoError(t, resp)
require.Equal(t, 0, len(posts.Order), "should return 0 post")
require.Empty(t, posts.Order, "should return 0 post")
require.Equal(t, "", posts.NextPostId, "should return an empty NextPostId")
require.Equal(t, nonExistentPostId, posts.PrevPostId, "should return nonExistentPostId as PrevPostId")
}
@@ -1931,7 +1931,7 @@ func TestSearchPosts(t *testing.T) {
posts2, resp = Client.SearchPostsWithParams(th.BasicTeam.Id, &searchParams)
CheckNoError(t, resp)
// We don't support paging for DB search yet, modify this when we do.
require.Len(t, posts2.Order, 0, "Wrong number of posts")
require.Empty(t, posts2.Order, "Wrong number of posts")
posts, resp = Client.SearchPosts(th.BasicTeam.Id, "search", false)
CheckNoError(t, resp)
@@ -1968,7 +1968,7 @@ func TestSearchPosts(t *testing.T) {
require.Len(t, posts.Order, 1, "wrong search")
posts, _ = Client.SearchPosts(th.BasicTeam.Id, "*", false)
require.Len(t, posts.Order, 0, "searching for just * shouldn't return any results")
require.Empty(t, posts.Order, "searching for just * shouldn't return any results")
posts, resp = Client.SearchPosts(th.BasicTeam.Id, "post1 post2", true)
CheckNoError(t, resp)
@@ -2033,10 +2033,10 @@ func TestSearchPostsInChannel(t *testing.T) {
_ = th.CreateMessagePostWithClient(Client, channel, message)
posts, _ := Client.SearchPosts(th.BasicTeam.Id, "channel:", false)
require.Len(t, posts.Order, 0, "wrong number of posts for search 'channel:'")
require.Empty(t, posts.Order, "wrong number of posts for search 'channel:'")
posts, _ = Client.SearchPosts(th.BasicTeam.Id, "in:", false)
require.Len(t, posts.Order, 0, "wrong number of posts for search 'in:'")
require.Empty(t, posts.Order, "wrong number of posts for search 'in:'")
posts, _ = Client.SearchPosts(th.BasicTeam.Id, "channel:"+th.BasicChannel.Name, false)
require.Lenf(t, posts.Order, 2, "wrong number of posts returned for search 'channel:%v'", th.BasicChannel.Name)
@@ -2144,13 +2144,13 @@ func TestSearchPostsWithDateFlags(t *testing.T) {
require.Len(t, posts.Order, 3, "wrong number of posts")
posts, _ = Client.SearchPosts(th.BasicTeam.Id, "on:", false)
require.Len(t, posts.Order, 0, "wrong number of posts")
require.Empty(t, posts.Order, "wrong number of posts")
posts, _ = Client.SearchPosts(th.BasicTeam.Id, "after:", false)
require.Len(t, posts.Order, 0, "wrong number of posts")
require.Empty(t, posts.Order, "wrong number of posts")
posts, _ = Client.SearchPosts(th.BasicTeam.Id, "before:", false)
require.Len(t, posts.Order, 0, "wrong number of posts")
require.Empty(t, posts.Order, "wrong number of posts")
posts, _ = Client.SearchPosts(th.BasicTeam.Id, "on:2018-08-01", false)
require.Len(t, posts.Order, 1, "wrong number of posts")
@@ -2168,7 +2168,7 @@ func TestSearchPostsWithDateFlags(t *testing.T) {
require.Len(t, posts.Order, 1, "wrong number of posts")
posts, _ = Client.SearchPosts(th.BasicTeam.Id, "before:2018-08-03 after:2018-08-02", false)
require.Len(t, posts.Order, 0, "wrong number of posts")
require.Empty(t, posts.Order, "wrong number of posts")
posts, _ = Client.SearchPosts(th.BasicTeam.Id, "before:2018-08-03 after:2018-08-01", false)
require.Len(t, posts.Order, 1, "wrong number of posts")
@@ -2210,7 +2210,7 @@ func TestGetFileInfosForPost(t *testing.T) {
infos, resp = Client.GetFileInfosForPost(th.BasicPost.Id, "")
CheckNoError(t, resp)
require.Len(t, infos, 0, "should have no file infos")
require.Empty(t, infos, "should have no file infos")
_, resp = Client.GetFileInfosForPost("junk", "")
CheckBadRequestStatus(t, resp)

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

@@ -890,12 +890,12 @@ func TestSearchAllTeams(t *testing.T) {
rteams, resp = Client.SearchTeams(&model.TeamSearch{Term: pTeam.Name})
CheckNoError(t, resp)
require.Len(t, rteams, 0, "should have not returned team")
require.Empty(t, rteams, "should have not returned team")
rteams, resp = Client.SearchTeams(&model.TeamSearch{Term: pTeam.DisplayName})
CheckNoError(t, resp)
require.Len(t, rteams, 0, "should have not returned team")
require.Empty(t, rteams, "should have not returned team")
rteams, resp = th.SystemAdminClient.SearchTeams(&model.TeamSearch{Term: oTeam.Name})
CheckNoError(t, resp)
@@ -910,7 +910,7 @@ func TestSearchAllTeams(t *testing.T) {
rteams, resp = Client.SearchTeams(&model.TeamSearch{Term: "junk"})
CheckNoError(t, resp)
require.Len(t, rteams, 0, "should have not returned team")
require.Empty(t, rteams, "should have not returned team")
Client.Logout()
@@ -1252,7 +1252,7 @@ func TestGetTeamMembers(t *testing.T) {
rmembers, resp = Client.GetTeamMembers(team.Id, 10000, 100, "")
CheckNoError(t, resp)
require.Len(t, rmembers, 0, "should be no member")
require.Empty(t, rmembers, "should be no member")
rmembers, resp = Client.GetTeamMembers(team.Id, 0, 2, "")
CheckNoError(t, resp)
@@ -2050,7 +2050,7 @@ func TestGetMyTeamsUnread(t *testing.T) {
teams, resp = Client.GetTeamsUnreadForUser(user.Id, th.BasicTeam.Id)
CheckNoError(t, resp)
require.Len(t, teams, 0, "should not have results")
require.Empty(t, teams, "should not have results")
_, resp = Client.GetTeamsUnreadForUser("fail", "")
CheckBadRequestStatus(t, resp)

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

@@ -1074,7 +1074,7 @@ func TestAutocompleteUsersInChannel(t *testing.T) {
rusers, resp = th.Client.AutocompleteUsersInChannel(teamId, channelId, "", model.USER_SEARCH_DEFAULT_LIMIT, "")
CheckNoError(t, resp)
assert.Len(t, rusers.OutOfChannel, 0)
assert.Empty(t, rusers.OutOfChannel)
th.App.GetOrCreateDirectChannel(permissionsUser.Id, otherUser.Id)
@@ -2025,11 +2025,11 @@ func TestGetUsersNotInTeam(t *testing.T) {
rusers, resp = th.Client.GetUsersNotInTeam(teamId, 1, 1, "")
CheckNoError(t, resp)
require.Len(t, rusers, 0, "should be no users")
require.Empty(t, rusers, "should be no users")
rusers, resp = th.Client.GetUsersNotInTeam(teamId, 10000, 100, "")
CheckNoError(t, resp)
require.Len(t, rusers, 0, "should be no users")
require.Empty(t, rusers, "should be no users")
th.Client.Logout()
_, resp = th.Client.GetUsersNotInTeam(teamId, 0, 60, "")
@@ -2065,7 +2065,7 @@ func TestGetUsersInChannel(t *testing.T) {
rusers, resp = th.Client.GetUsersInChannel(channelId, 10000, 100, "")
CheckNoError(t, resp)
require.Len(t, rusers, 0, "should be no users")
require.Empty(t, rusers, "should be no users")
th.Client.Logout()
_, resp = th.Client.GetUsersInChannel(channelId, 0, 60, "")
@@ -2101,7 +2101,7 @@ func TestGetUsersNotInChannel(t *testing.T) {
rusers, resp = th.Client.GetUsersNotInChannel(teamId, channelId, 10000, 100, "")
CheckNoError(t, resp)
require.Len(t, rusers, 0, "should be no users")
require.Empty(t, rusers, "should be no users")
th.Client.Logout()
_, resp = th.Client.GetUsersNotInChannel(teamId, channelId, 0, 60, "")
@@ -3648,7 +3648,7 @@ func TestSearchUserAccessToken(t *testing.T) {
rtokens, resp = th.SystemAdminClient.SearchUserAccessTokens(&model.UserAccessTokenSearch{Term: "not found"})
CheckNoError(t, resp)
require.Len(t, rtokens, 0, "should have 1 tokens")
require.Empty(t, rtokens, "should have 1 tokens")
}
func TestRevokeUserAccessToken(t *testing.T) {

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

@@ -150,7 +150,7 @@ func TestGetIncomingWebhooks(t *testing.T) {
hooks, resp = th.SystemAdminClient.GetIncomingWebhooksForTeam(model.NewId(), 0, 1000, "")
CheckNoError(t, resp)
require.Len(t, hooks, 0, "no hooks should be returned")
require.Empty(t, hooks, "no hooks should be returned")
_, resp = Client.GetIncomingWebhooks(0, 1000, "")
CheckForbiddenStatus(t, resp)
@@ -437,7 +437,7 @@ func TestGetOutgoingWebhooks(t *testing.T) {
hooks, resp = th.SystemAdminClient.GetOutgoingWebhooksForTeam(model.NewId(), 0, 1000, "")
CheckNoError(t, resp)
require.Len(t, hooks, 0, "no hooks should be returned")
require.Empty(t, hooks, "no hooks should be returned")
hooks, resp = th.SystemAdminClient.GetOutgoingWebhooksForChannel(th.BasicChannel.Id, 0, 1000, "")
CheckNoError(t, resp)

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

@@ -653,11 +653,11 @@ func TestNotifySysadminsBotOwnerDisabled(t *testing.T) {
// get posts from sysadmin1 and sysadmin2 DM channels
posts1, err := th.App.GetPosts(channelSys1.Id, 0, 5)
require.Nil(t, err)
assert.Len(t, posts1.Order, 0)
assert.Empty(t, posts1.Order)
posts2, err := th.App.GetPosts(channelSys2.Id, 0, 5)
require.Nil(t, err)
assert.Len(t, posts2.Order, 0)
assert.Empty(t, posts2.Order)
// send notification for user with bots
err = th.App.notifySysadminsBotOwnerDeactivated(user1.Id)

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

@@ -4,10 +4,11 @@
package app
import (
"github.com/stretchr/testify/assert"
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/mattermost/mattermost-server/v5/model"
"github.com/stretchr/testify/require"
)
@@ -25,10 +26,10 @@ func TestHandleNewNotifications(t *testing.T) {
job.handleNewNotifications()
require.Len(t, job.pendingNotifications, 0, "shouldn't have added any pending notifications")
require.Empty(t, job.pendingNotifications, "shouldn't have added any pending notifications")
job.Add(&model.User{Id: id1}, &model.Post{UserId: id1, Message: "test"}, &model.Team{Name: "team"})
require.Len(t, job.pendingNotifications, 0, "shouldn't have added any pending notifications")
require.Empty(t, job.pendingNotifications, "shouldn't have added any pending notifications")
job.handleNewNotifications()
require.Len(t, job.pendingNotifications, 1, "should have received posts for 1 user")
@@ -117,7 +118,7 @@ func TestCheckPendingNotifications(t *testing.T) {
job.checkPendingNotifications(time.Unix(10002, 0), func(string, []*batchedNotification) {})
require.Nil(t, job.pendingNotifications[th.BasicUser.Id])
require.Len(t, job.pendingNotifications[th.BasicUser.Id], 0, "should've remove queued post since user acted")
require.Empty(t, job.pendingNotifications[th.BasicUser.Id], "should've remove queued post since user acted")
// test that notifications are sent if enough time passes since the first message
job.pendingNotifications[th.BasicUser.Id] = []*batchedNotification{
@@ -210,7 +211,7 @@ func TestCheckPendingNotificationsDefaultInterval(t *testing.T) {
// notifications should be sent 901s after post was created, because default batch interval is 15mins
job.checkPendingNotifications(time.Unix(10901, 0), func(string, []*batchedNotification) {})
require.Nil(t, job.pendingNotifications[th.BasicUser.Id])
require.Len(t, job.pendingNotifications[th.BasicUser.Id], 0, "should have sent queued post")
require.Empty(t, job.pendingNotifications[th.BasicUser.Id], "should have sent queued post")
}
/**

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

@@ -834,7 +834,7 @@ func TestImportImportUser(t *testing.T) {
require.Equal(t, user.AuthData, data.AuthData, "Expected AuthData to be set.")
require.Len(t, user.Password, 0, "Expected password to be empty.")
require.Empty(t, user.Password, "Expected password to be empty.")
require.True(t, user.EmailVerified, "Expected EmailVerified to be true.")
@@ -2190,7 +2190,7 @@ func TestImportImportDirectPost(t *testing.T) {
// Check the post values.
posts, err := th.App.Srv.Store.Post().GetPostsCreatedAt(directChannel.Id, *data.CreateAt)
require.Nil(t, err)
require.Equal(t, len(posts), 1)
require.Len(t, posts, 1)
post := posts[0]
require.Equal(t, post.Message, *data.Message)
@@ -2205,7 +2205,7 @@ func TestImportImportDirectPost(t *testing.T) {
// Check the post values.
posts, err = th.App.Srv.Store.Post().GetPostsCreatedAt(directChannel.Id, *data.CreateAt)
require.Nil(t, err)
require.Equal(t, len(posts), 1)
require.Len(t, posts, 1)
post = posts[0]
require.Equal(t, post.Message, *data.Message)
@@ -2233,7 +2233,7 @@ func TestImportImportDirectPost(t *testing.T) {
posts, err = th.App.Srv.Store.Post().GetPostsCreatedAt(directChannel.Id, *data.CreateAt)
require.Nil(t, err)
require.Equal(t, len(posts), 1)
require.Len(t, posts, 1)
post = posts[0]
require.Equal(t, post.Message, *data.Message)
@@ -2262,7 +2262,7 @@ func TestImportImportDirectPost(t *testing.T) {
// Check the post values.
posts, err = th.App.Srv.Store.Post().GetPostsCreatedAt(directChannel.Id, *data.CreateAt)
require.Nil(t, err)
require.Equal(t, len(posts), 1)
require.Len(t, posts, 1)
post = posts[0]
checkPreference(t, th.App, th.BasicUser.Id, model.PREFERENCE_CATEGORY_FLAGGED_POST, post.Id, "true")
@@ -2361,7 +2361,7 @@ func TestImportImportDirectPost(t *testing.T) {
// Check the post values.
posts, err = th.App.Srv.Store.Post().GetPostsCreatedAt(groupChannel.Id, *data.CreateAt)
require.Nil(t, err)
require.Equal(t, len(posts), 1)
require.Len(t, posts, 1)
post = posts[0]
require.Equal(t, post.Message, *data.Message)
@@ -2376,7 +2376,7 @@ func TestImportImportDirectPost(t *testing.T) {
// Check the post values.
posts, err = th.App.Srv.Store.Post().GetPostsCreatedAt(groupChannel.Id, *data.CreateAt)
require.Nil(t, err)
require.Equal(t, len(posts), 1)
require.Len(t, posts, 1)
post = posts[0]
require.Equal(t, post.Message, *data.Message)
@@ -2404,7 +2404,7 @@ func TestImportImportDirectPost(t *testing.T) {
posts, err = th.App.Srv.Store.Post().GetPostsCreatedAt(groupChannel.Id, *data.CreateAt)
require.Nil(t, err)
require.Equal(t, len(posts), 1)
require.Len(t, posts, 1)
post = posts[0]
require.Equal(t, post.Message, *data.Message)
@@ -2434,7 +2434,7 @@ func TestImportImportDirectPost(t *testing.T) {
// Check the post values.
posts, err = th.App.Srv.Store.Post().GetPostsCreatedAt(groupChannel.Id, *data.CreateAt)
require.Nil(t, err)
require.Equal(t, len(posts), 1)
require.Len(t, posts, 1)
post = posts[0]
checkPreference(t, th.App, th.BasicUser.Id, model.PREFERENCE_CATEGORY_FLAGGED_POST, post.Id, "true")
@@ -2497,7 +2497,7 @@ func TestImportAttachment(t *testing.T) {
assert.Nil(t, err, "sample run without errors")
attachments := GetAttachments(userId, th, t)
assert.Equal(t, len(attachments), 1)
assert.Len(t, attachments, 1)
data = AttachmentImportData{Path: &invalidPath}
_, err = th.App.ImportAttachment(&data, &model.Post{UserId: model.NewId(), ChannelId: "some-channel"}, "some-team", true)
@@ -2574,7 +2574,7 @@ func TestImportPostAndRepliesWithAttachments(t *testing.T) {
assert.Nil(t, err)
attachments := GetAttachments(user3.Id, th, t)
assert.Equal(t, len(attachments), 2)
assert.Len(t, attachments, 2)
assert.Contains(t, attachments[0].Path, team.Id)
assert.Contains(t, attachments[1].Path, team.Id)
AssertFileIdsInPost(attachments, th, t)
@@ -2585,12 +2585,12 @@ func TestImportPostAndRepliesWithAttachments(t *testing.T) {
assert.Nil(t, err)
attachments = GetAttachments(user3.Id, th, t)
assert.Equal(t, len(attachments), 1)
assert.Len(t, attachments, 1)
assert.Contains(t, attachments[0].Path, team.Id)
AssertFileIdsInPost(attachments, th, t)
attachments = GetAttachments(user4.Id, th, t)
assert.Equal(t, len(attachments), 1)
assert.Len(t, attachments, 1)
assert.Contains(t, attachments[0].Path, team.Id)
AssertFileIdsInPost(attachments, th, t)
@@ -2635,7 +2635,7 @@ func TestImportPostAndRepliesWithAttachments(t *testing.T) {
require.Nil(t, err, "Expected success.")
attachments = GetAttachments(user4.Id, th, t)
assert.Equal(t, len(attachments), 1)
assert.Len(t, attachments, 1)
assert.Contains(t, attachments[0].Path, "noteam")
AssertFileIdsInPost(attachments, th, t)
}
@@ -2690,7 +2690,7 @@ func TestImportDirectPostWithAttachments(t *testing.T) {
require.Nil(t, err, "Expected success.")
attachments := GetAttachments(user1.Id, th, t)
assert.Equal(t, len(attachments), 1)
assert.Len(t, attachments, 1)
assert.Contains(t, attachments[0].Path, "noteam")
AssertFileIdsInPost(attachments, th, t)
})
@@ -2700,7 +2700,7 @@ func TestImportDirectPostWithAttachments(t *testing.T) {
require.Nil(t, err, "Expected success.")
attachments := GetAttachments(user1.Id, th, t)
assert.Equal(t, len(attachments), 1)
assert.Len(t, attachments, 1)
})
t.Run("Attempt to import again with same name and size but different content, SHOULD add an attachment", func(t *testing.T) {
@@ -2719,7 +2719,7 @@ func TestImportDirectPostWithAttachments(t *testing.T) {
require.Nil(t, err, "Expected success.")
attachments := GetAttachments(user1.Id, th, t)
assert.Equal(t, len(attachments), 2)
assert.Len(t, attachments, 2)
})
t.Run("Attempt to import again with same data, SHOULD add an attachment, since it's different name", func(t *testing.T) {
@@ -2738,6 +2738,6 @@ func TestImportDirectPostWithAttachments(t *testing.T) {
require.Nil(t, err, "Expected success.")
attachments := GetAttachments(user1.Id, th, t)
assert.Equal(t, len(attachments), 3)
assert.Len(t, attachments, 3)
})
}

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

@@ -67,7 +67,7 @@ func TestSendNotifications(t *testing.T) {
th.BasicChannel.DeleteAt = 1
mentions, err = th.App.SendNotifications(post1, th.BasicTeam, th.BasicChannel, th.BasicUser, nil)
require.NoError(t, err)
require.Len(t, mentions, 0)
require.Empty(t, mentions)
}
func TestSendNotificationsWithManyUsers(t *testing.T) {

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

@@ -528,7 +528,7 @@ func TestPluginSync(t *testing.T) {
// Check if removed
pluginStatus, err = env.Statuses()
require.Nil(t, err)
require.Len(t, pluginStatus, 0)
require.Empty(t, pluginStatus)
// RequirePluginSignature = true case
th.App.UpdateConfig(func(cfg *model.Config) {
@@ -544,7 +544,7 @@ func TestPluginSync(t *testing.T) {
checkNoError(t, appErr)
pluginStatus, err = env.Statuses()
require.Nil(t, err)
require.Len(t, pluginStatus, 0)
require.Empty(t, pluginStatus)
// Wrong signature
signatureFileReader, err := os.Open(filepath.Join(path, "testpluginv2.tar.gz.sig"))
@@ -559,7 +559,7 @@ func TestPluginSync(t *testing.T) {
pluginStatus, err = env.Statuses()
require.Nil(t, err)
require.Len(t, pluginStatus, 0)
require.Empty(t, pluginStatus)
// Correct signature
key, err := os.Open(filepath.Join(path, "development-private-key.asc"))

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

@@ -132,11 +132,11 @@ func TestPreparePostForClient(t *testing.T) {
t.Run("populates all fields", func(t *testing.T) {
assert.Equal(t, message, clientPost.Message, "shouldn't have changed Message")
assert.NotEqual(t, nil, clientPost.Metadata, "should've populated Metadata")
assert.Len(t, clientPost.Metadata.Embeds, 0, "should've populated Embeds")
assert.Len(t, clientPost.Metadata.Reactions, 0, "should've populated Reactions")
assert.Len(t, clientPost.Metadata.Files, 0, "should've populated Files")
assert.Len(t, clientPost.Metadata.Emojis, 0, "should've populated Emojis")
assert.Len(t, clientPost.Metadata.Images, 0, "should've populated Images")
assert.Empty(t, clientPost.Metadata.Embeds, "should've populated Embeds")
assert.Empty(t, clientPost.Metadata.Reactions, "should've populated Reactions")
assert.Empty(t, clientPost.Metadata.Files, "should've populated Files")
assert.Empty(t, clientPost.Metadata.Emojis, "should've populated Emojis")
assert.Empty(t, clientPost.Metadata.Images, "should've populated Images")
})
})

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

@@ -833,7 +833,7 @@ func TestGetViewUsersRestrictions(t *testing.T) {
require.Nil(t, err)
assert.NotNil(t, restrictions)
assert.Len(t, restrictions.Teams, 0)
assert.Empty(t, restrictions.Teams)
assert.NotNil(t, restrictions.Channels)
assert.ElementsMatch(t, []string{team1townsquare.Id, team1offtopic.Id, team1channel1.Id, team1channel2.Id, team2townsquare.Id, team2offtopic.Id, team2channel1.Id}, restrictions.Channels)
})

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

@@ -316,9 +316,9 @@ func TestTruncateOpenGraph(t *testing.T) {
assert.Nil(t, result.Book, "No book stored")
assert.Nil(t, result.Profile, "No profile stored")
assert.Len(t, result.Images, 5, "Only the first 5 images")
assert.Len(t, result.Audios, 0, "No audios stored")
assert.Len(t, result.Videos, 0, "No videos stored")
assert.Len(t, result.LocalesAlternate, 0, "No alternate locales stored")
assert.Empty(t, result.Audios, "No audios stored")
assert.Empty(t, result.Videos, "No videos stored")
assert.Empty(t, result.LocalesAlternate, "No alternate locales stored")
assert.Equal(t, result.Determiner, "", "No determiner stored")
assert.Equal(t, utf8.RuneCountInString(result.Title), 305, "Title text is truncated")
assert.Equal(t, utf8.RuneCountInString(result.Description), 305, "Description text is truncated")

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

@@ -49,5 +49,5 @@ func TestSecurityBulletinsToFromJson(t *testing.T) {
s2 := `{"wat"`
b2 := SecurityBulletinsFromJson(strings.NewReader(s2))
require.Len(t, b2, 0)
require.Empty(t, b2)
}

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

@@ -353,7 +353,7 @@ func TestCheckIntegrity(t *testing.T) {
require.Nil(t, result.Err)
switch data := result.Data.(type) {
case store.RelationalIntegrityCheckData:
require.Len(t, data.Records, 0)
require.Empty(t, data.Records)
}
}
})
@@ -386,7 +386,7 @@ func TestCheckChannelsCommandWebhooksIntegrity(t *testing.T) {
result := checkChannelsCommandWebhooksIntegrity(supplier)
require.Nil(t, result.Err)
data := result.Data.(store.RelationalIntegrityCheckData)
require.Len(t, data.Records, 0)
require.Empty(t, data.Records)
})
t.Run("should generate a report with one record", func(t *testing.T) {
@@ -414,7 +414,7 @@ func TestCheckChannelsChannelMemberHistoryIntegrity(t *testing.T) {
result := checkChannelsChannelMemberHistoryIntegrity(supplier)
require.Nil(t, result.Err)
data := result.Data.(store.RelationalIntegrityCheckData)
require.Len(t, data.Records, 0)
require.Empty(t, data.Records)
})
t.Run("should generate a report with one record", func(t *testing.T) {
@@ -444,7 +444,7 @@ func TestCheckChannelsChannelMembersIntegrity(t *testing.T) {
result := checkChannelsChannelMembersIntegrity(supplier)
require.Nil(t, result.Err)
data := result.Data.(store.RelationalIntegrityCheckData)
require.Len(t, data.Records, 0)
require.Empty(t, data.Records)
})
t.Run("should generate a report with one record", func(t *testing.T) {
@@ -472,7 +472,7 @@ func TestCheckChannelsIncomingWebhooksIntegrity(t *testing.T) {
result := checkChannelsIncomingWebhooksIntegrity(supplier)
require.Nil(t, result.Err)
data := result.Data.(store.RelationalIntegrityCheckData)
require.Len(t, data.Records, 0)
require.Empty(t, data.Records)
})
t.Run("should generate a report with one record", func(t *testing.T) {
@@ -500,7 +500,7 @@ func TestCheckChannelsOutgoingWebhooksIntegrity(t *testing.T) {
result := checkChannelsOutgoingWebhooksIntegrity(supplier)
require.Nil(t, result.Err)
data := result.Data.(store.RelationalIntegrityCheckData)
require.Len(t, data.Records, 0)
require.Empty(t, data.Records)
})
t.Run("should generate a report with one record", func(t *testing.T) {
@@ -530,7 +530,7 @@ func TestCheckChannelsPostsIntegrity(t *testing.T) {
result := checkChannelsPostsIntegrity(supplier)
require.Nil(t, result.Err)
data := result.Data.(store.RelationalIntegrityCheckData)
require.Len(t, data.Records, 0)
require.Empty(t, data.Records)
})
t.Run("should generate a report with one record", func(t *testing.T) {
@@ -557,7 +557,7 @@ func TestCheckCommandsCommandWebhooksIntegrity(t *testing.T) {
result := checkCommandsCommandWebhooksIntegrity(supplier)
require.Nil(t, result.Err)
data := result.Data.(store.RelationalIntegrityCheckData)
require.Len(t, data.Records, 0)
require.Empty(t, data.Records)
})
t.Run("should generate a report with one record", func(t *testing.T) {
@@ -585,7 +585,7 @@ func TestCheckPostsFileInfoIntegrity(t *testing.T) {
result := checkPostsFileInfoIntegrity(supplier)
require.Nil(t, result.Err)
data := result.Data.(store.RelationalIntegrityCheckData)
require.Len(t, data.Records, 0)
require.Empty(t, data.Records)
})
t.Run("should generate a report with one record", func(t *testing.T) {
@@ -613,7 +613,7 @@ func TestCheckPostsPostsParentIdIntegrity(t *testing.T) {
result := checkPostsPostsParentIdIntegrity(supplier)
require.Nil(t, result.Err)
data := result.Data.(store.RelationalIntegrityCheckData)
require.Len(t, data.Records, 0)
require.Empty(t, data.Records)
})
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -623,7 +623,7 @@ func TestCheckPostsPostsParentIdIntegrity(t *testing.T) {
result := checkPostsPostsParentIdIntegrity(supplier)
require.Nil(t, result.Err)
data := result.Data.(store.RelationalIntegrityCheckData)
require.Len(t, data.Records, 0)
require.Empty(t, data.Records)
dbmap.Delete(parent)
dbmap.Delete(root)
dbmap.Delete(post)
@@ -658,7 +658,7 @@ func TestCheckPostsPostsRootIdIntegrity(t *testing.T) {
result := checkPostsPostsRootIdIntegrity(supplier)
require.Nil(t, result.Err)
data := result.Data.(store.RelationalIntegrityCheckData)
require.Len(t, data.Records, 0)
require.Empty(t, data.Records)
})
t.Run("should generate a report with one record", func(t *testing.T) {
@@ -688,7 +688,7 @@ func TestCheckPostsReactionsIntegrity(t *testing.T) {
result := checkPostsReactionsIntegrity(supplier)
require.Nil(t, result.Err)
data := result.Data.(store.RelationalIntegrityCheckData)
require.Len(t, data.Records, 0)
require.Empty(t, data.Records)
})
t.Run("should generate a report with one record", func(t *testing.T) {
@@ -715,7 +715,7 @@ func TestCheckSchemesChannelsIntegrity(t *testing.T) {
result := checkSchemesChannelsIntegrity(supplier)
require.Nil(t, result.Err)
data := result.Data.(store.RelationalIntegrityCheckData)
require.Len(t, data.Records, 0)
require.Empty(t, data.Records)
})
t.Run("should generate a report with one record", func(t *testing.T) {
@@ -746,7 +746,7 @@ func TestCheckSchemesTeamsIntegrity(t *testing.T) {
result := checkSchemesTeamsIntegrity(supplier)
require.Nil(t, result.Err)
data := result.Data.(store.RelationalIntegrityCheckData)
require.Len(t, data.Records, 0)
require.Empty(t, data.Records)
})
t.Run("should generate a report with one record", func(t *testing.T) {
@@ -777,7 +777,7 @@ func TestCheckSessionsAuditsIntegrity(t *testing.T) {
result := checkSessionsAuditsIntegrity(supplier)
require.Nil(t, result.Err)
data := result.Data.(store.RelationalIntegrityCheckData)
require.Len(t, data.Records, 0)
require.Empty(t, data.Records)
})
t.Run("should generate a report with one record", func(t *testing.T) {
@@ -808,7 +808,7 @@ func TestCheckTeamsChannelsIntegrity(t *testing.T) {
result := checkTeamsChannelsIntegrity(supplier)
require.Nil(t, result.Err)
data := result.Data.(store.RelationalIntegrityCheckData)
require.Len(t, data.Records, 0)
require.Empty(t, data.Records)
})
t.Run("should generate a report with one record", func(t *testing.T) {
@@ -835,7 +835,7 @@ func TestCheckTeamsCommandsIntegrity(t *testing.T) {
result := checkTeamsCommandsIntegrity(supplier)
require.Nil(t, result.Err)
data := result.Data.(store.RelationalIntegrityCheckData)
require.Len(t, data.Records, 0)
require.Empty(t, data.Records)
})
t.Run("should generate a report with one record", func(t *testing.T) {
@@ -863,7 +863,7 @@ func TestCheckTeamsIncomingWebhooksIntegrity(t *testing.T) {
result := checkTeamsIncomingWebhooksIntegrity(supplier)
require.Nil(t, result.Err)
data := result.Data.(store.RelationalIntegrityCheckData)
require.Len(t, data.Records, 0)
require.Empty(t, data.Records)
})
t.Run("should generate a report with one record", func(t *testing.T) {
@@ -891,7 +891,7 @@ func TestCheckTeamsOutgoingWebhooksIntegrity(t *testing.T) {
result := checkTeamsOutgoingWebhooksIntegrity(supplier)
require.Nil(t, result.Err)
data := result.Data.(store.RelationalIntegrityCheckData)
require.Len(t, data.Records, 0)
require.Empty(t, data.Records)
})
t.Run("should generate a report with one record", func(t *testing.T) {
@@ -919,7 +919,7 @@ func TestCheckTeamsTeamMembersIntegrity(t *testing.T) {
result := checkTeamsTeamMembersIntegrity(supplier)
require.Nil(t, result.Err)
data := result.Data.(store.RelationalIntegrityCheckData)
require.Len(t, data.Records, 0)
require.Empty(t, data.Records)
})
t.Run("should generate a report with one record", func(t *testing.T) {
@@ -947,7 +947,7 @@ func TestCheckUsersAuditsIntegrity(t *testing.T) {
result := checkUsersAuditsIntegrity(supplier)
require.Nil(t, result.Err)
data := result.Data.(store.RelationalIntegrityCheckData)
require.Len(t, data.Records, 0)
require.Empty(t, data.Records)
})
t.Run("should generate a report with one record", func(t *testing.T) {
@@ -977,7 +977,7 @@ func TestCheckUsersCommandWebhooksIntegrity(t *testing.T) {
result := checkUsersCommandWebhooksIntegrity(supplier)
require.Nil(t, result.Err)
data := result.Data.(store.RelationalIntegrityCheckData)
require.Len(t, data.Records, 0)
require.Empty(t, data.Records)
})
t.Run("should generate a report with one record", func(t *testing.T) {
@@ -1005,7 +1005,7 @@ func TestCheckUsersChannelsIntegrity(t *testing.T) {
result := checkUsersChannelsIntegrity(supplier)
require.Nil(t, result.Err)
data := result.Data.(store.RelationalIntegrityCheckData)
require.Len(t, data.Records, 0)
require.Empty(t, data.Records)
})
t.Run("should generate a report with one record", func(t *testing.T) {
@@ -1032,7 +1032,7 @@ func TestCheckUsersChannelMemberHistoryIntegrity(t *testing.T) {
result := checkUsersChannelMemberHistoryIntegrity(supplier)
require.Nil(t, result.Err)
data := result.Data.(store.RelationalIntegrityCheckData)
require.Len(t, data.Records, 0)
require.Empty(t, data.Records)
})
t.Run("should generate a report with one record", func(t *testing.T) {
@@ -1062,7 +1062,7 @@ func TestCheckUsersChannelMembersIntegrity(t *testing.T) {
result := checkUsersChannelMembersIntegrity(supplier)
require.Nil(t, result.Err)
data := result.Data.(store.RelationalIntegrityCheckData)
require.Len(t, data.Records, 0)
require.Empty(t, data.Records)
})
t.Run("should generate a report with one record", func(t *testing.T) {
@@ -1092,7 +1092,7 @@ func TestCheckUsersCommandsIntegrity(t *testing.T) {
result := checkUsersCommandsIntegrity(supplier)
require.Nil(t, result.Err)
data := result.Data.(store.RelationalIntegrityCheckData)
require.Len(t, data.Records, 0)
require.Empty(t, data.Records)
})
t.Run("should generate a report with one record", func(t *testing.T) {
@@ -1120,7 +1120,7 @@ func TestCheckUsersCompliancesIntegrity(t *testing.T) {
result := checkUsersCompliancesIntegrity(supplier)
require.Nil(t, result.Err)
data := result.Data.(store.RelationalIntegrityCheckData)
require.Len(t, data.Records, 0)
require.Empty(t, data.Records)
})
t.Run("should generate a report with one record", func(t *testing.T) {
@@ -1150,7 +1150,7 @@ func TestCheckUsersEmojiIntegrity(t *testing.T) {
result := checkUsersEmojiIntegrity(supplier)
require.Nil(t, result.Err)
data := result.Data.(store.RelationalIntegrityCheckData)
require.Len(t, data.Records, 0)
require.Empty(t, data.Records)
})
t.Run("should generate a report with one record", func(t *testing.T) {
@@ -1180,7 +1180,7 @@ func TestCheckUsersFileInfoIntegrity(t *testing.T) {
result := checkUsersFileInfoIntegrity(supplier)
require.Nil(t, result.Err)
data := result.Data.(store.RelationalIntegrityCheckData)
require.Len(t, data.Records, 0)
require.Empty(t, data.Records)
})
t.Run("should generate a report with one record", func(t *testing.T) {
@@ -1210,7 +1210,7 @@ func TestCheckUsersIncomingWebhooksIntegrity(t *testing.T) {
result := checkUsersIncomingWebhooksIntegrity(supplier)
require.Nil(t, result.Err)
data := result.Data.(store.RelationalIntegrityCheckData)
require.Len(t, data.Records, 0)
require.Empty(t, data.Records)
})
t.Run("should generate a report with one record", func(t *testing.T) {
@@ -1238,7 +1238,7 @@ func TestCheckUsersOAuthAccessDataIntegrity(t *testing.T) {
result := checkUsersOAuthAccessDataIntegrity(supplier)
require.Nil(t, result.Err)
data := result.Data.(store.RelationalIntegrityCheckData)
require.Len(t, data.Records, 0)
require.Empty(t, data.Records)
})
t.Run("should generate a report with one record", func(t *testing.T) {
@@ -1268,7 +1268,7 @@ func TestCheckUsersOAuthAppsIntegrity(t *testing.T) {
result := checkUsersOAuthAppsIntegrity(supplier)
require.Nil(t, result.Err)
data := result.Data.(store.RelationalIntegrityCheckData)
require.Len(t, data.Records, 0)
require.Empty(t, data.Records)
})
t.Run("should generate a report with one record", func(t *testing.T) {
@@ -1298,7 +1298,7 @@ func TestCheckUsersOAuthAuthDataIntegrity(t *testing.T) {
result := checkUsersOAuthAuthDataIntegrity(supplier)
require.Nil(t, result.Err)
data := result.Data.(store.RelationalIntegrityCheckData)
require.Len(t, data.Records, 0)
require.Empty(t, data.Records)
})
t.Run("should generate a report with one record", func(t *testing.T) {
@@ -1328,7 +1328,7 @@ func TestCheckUsersOutgoingWebhooksIntegrity(t *testing.T) {
result := checkUsersOutgoingWebhooksIntegrity(supplier)
require.Nil(t, result.Err)
data := result.Data.(store.RelationalIntegrityCheckData)
require.Len(t, data.Records, 0)
require.Empty(t, data.Records)
})
t.Run("should generate a report with one record", func(t *testing.T) {
@@ -1356,7 +1356,7 @@ func TestCheckUsersPostsIntegrity(t *testing.T) {
result := checkUsersPostsIntegrity(supplier)
require.Nil(t, result.Err)
data := result.Data.(store.RelationalIntegrityCheckData)
require.Len(t, data.Records, 0)
require.Empty(t, data.Records)
})
t.Run("should generate a report with one record", func(t *testing.T) {
@@ -1383,7 +1383,7 @@ func TestCheckUsersPreferencesIntegrity(t *testing.T) {
result := checkUsersPreferencesIntegrity(supplier)
require.Nil(t, result.Err)
data := result.Data.(store.RelationalIntegrityCheckData)
require.Len(t, data.Records, 0)
require.Empty(t, data.Records)
})
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -1395,7 +1395,7 @@ func TestCheckUsersPreferencesIntegrity(t *testing.T) {
result := checkUsersPreferencesIntegrity(supplier)
require.Nil(t, result.Err)
data := result.Data.(store.RelationalIntegrityCheckData)
require.Len(t, data.Records, 0)
require.Empty(t, data.Records)
dbmap.Exec(`DELETE FROM Preferences`)
dbmap.Delete(user)
})
@@ -1429,7 +1429,7 @@ func TestCheckUsersReactionsIntegrity(t *testing.T) {
result := checkUsersReactionsIntegrity(supplier)
require.Nil(t, result.Err)
data := result.Data.(store.RelationalIntegrityCheckData)
require.Len(t, data.Records, 0)
require.Empty(t, data.Records)
})
t.Run("should generate a report with one record", func(t *testing.T) {
@@ -1458,7 +1458,7 @@ func TestCheckUsersSessionsIntegrity(t *testing.T) {
result := checkUsersSessionsIntegrity(supplier)
require.Nil(t, result.Err)
data := result.Data.(store.RelationalIntegrityCheckData)
require.Len(t, data.Records, 0)
require.Empty(t, data.Records)
})
t.Run("should generate a report with one record", func(t *testing.T) {
@@ -1486,7 +1486,7 @@ func TestCheckUsersStatusIntegrity(t *testing.T) {
result := checkUsersStatusIntegrity(supplier)
require.Nil(t, result.Err)
data := result.Data.(store.RelationalIntegrityCheckData)
require.Len(t, data.Records, 0)
require.Empty(t, data.Records)
})
t.Run("should generate a report with one record", func(t *testing.T) {
@@ -1515,7 +1515,7 @@ func TestCheckUsersTeamMembersIntegrity(t *testing.T) {
result := checkUsersTeamMembersIntegrity(supplier)
require.Nil(t, result.Err)
data := result.Data.(store.RelationalIntegrityCheckData)
require.Len(t, data.Records, 0)
require.Empty(t, data.Records)
})
t.Run("should generate a report with one record", func(t *testing.T) {
@@ -1545,7 +1545,7 @@ func TestCheckUsersUserAccessTokensIntegrity(t *testing.T) {
result := checkUsersUserAccessTokensIntegrity(supplier)
require.Nil(t, result.Err)
data := result.Data.(store.RelationalIntegrityCheckData)
require.Len(t, data.Records, 0)
require.Empty(t, data.Records)
})
t.Run("should generate a report with one record", func(t *testing.T) {

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

@@ -230,7 +230,7 @@ func TestGetAllConns(t *testing.T) {
}
supplier := sqlstore.NewSqlSupplier(settings, nil)
assert.Equal(t, testCase.ExpectedNumConnections, len(supplier.GetAllConns()))
assert.Len(t, supplier.GetAllConns(), testCase.ExpectedNumConnections)
})
}
}

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

@@ -40,7 +40,7 @@ func testAuditStore(t *testing.T, ss store.Store) {
audits, err = ss.Audit().Get("missing", 0, 100)
require.Nil(t, err)
assert.Len(t, audits, 0)
assert.Empty(t, audits)
audits, err = ss.Audit().Get("", 0, 100)
require.Nil(t, err)

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

@@ -117,7 +117,7 @@ func testGetUsersInChannelAtChannelMemberHistory(t *testing.T, ss store.Store) {
// case 1: user joins and leaves the channel before the export period begins
channelMembers, err := ss.ChannelMemberHistory().GetUsersInChannelDuring(joinTime-500, joinTime-100, channel.Id)
require.Nil(t, err)
assert.Len(t, channelMembers, 0)
assert.Empty(t, channelMembers)
// case 2: user joins the channel after the export period begins, but has not yet left the channel when the export period ends
channelMembers, err = ss.ChannelMemberHistory().GetUsersInChannelDuring(joinTime-100, joinTime+500, channel.Id)
@@ -170,7 +170,7 @@ func testGetUsersInChannelAtChannelMemberHistory(t *testing.T, ss store.Store) {
// case 6: user has joined and left the channel long before the export period begins
channelMembers, err = ss.ChannelMemberHistory().GetUsersInChannelDuring(leaveTime+100, leaveTime+200, channel.Id)
require.Nil(t, err)
assert.Len(t, channelMembers, 0)
assert.Empty(t, channelMembers)
}
func testGetUsersInChannelAtChannelMembers(t *testing.T, ss store.Store) {

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

@@ -679,7 +679,7 @@ func testChannelStoreGetByNames(t *testing.T, ss store.Store) {
channels, err := ss.Channel().GetByNames(o1.TeamId, []string{o1.Name}, false)
require.Nil(t, err)
assert.Len(t, channels, 0)
assert.Empty(t, channels)
}
func testChannelStoreGetDeletedByName(t *testing.T, ss store.Store) {
@@ -3335,7 +3335,7 @@ func testChannelStoreGetPinnedPosts(t *testing.T, ss store.Store) {
pl, errGet = ss.Channel().GetPinnedPosts(o2.Id)
require.Nil(t, errGet, errGet)
require.Len(t, pl.Posts, 0, "wasn't supposed to return posts")
require.Empty(t, pl.Posts, "wasn't supposed to return posts")
}
func testChannelStoreGetPinnedPostCount(t *testing.T, ss store.Store) {
@@ -3471,12 +3471,12 @@ func testChannelStoreGetChannelsByScheme(t *testing.T, ss store.Store) {
// Get the channels by a valid Scheme ID where there aren't any matching Channel.
d2, err := ss.Channel().GetChannelsByScheme(s2.Id, 0, 100)
assert.Nil(t, err)
assert.Len(t, d2, 0)
assert.Empty(t, d2)
// Get the channels by an invalid Scheme ID.
d3, err := ss.Channel().GetChannelsByScheme(model.NewId(), 0, 100)
assert.Nil(t, err)
assert.Len(t, d3, 0)
assert.Empty(t, d3)
}
func testChannelStoreMigrateChannelMembers(t *testing.T, ss store.Store) {

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

@@ -152,5 +152,5 @@ func testClusterDiscoveryGetStore(t *testing.T, ss store.Store) {
list, err = ss.ClusterDiscovery().GetAll(model.NewId(), "cluster_name")
require.Nil(t, err)
assert.Len(t, list, 0)
assert.Empty(t, list)
}

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

@@ -168,7 +168,7 @@ func testEmojiGetMultipleByName(t *testing.T, ss store.Store) {
t.Run("one nonexistent emoji", func(t *testing.T) {
received, err := ss.Emoji().GetMultipleByName([]string{"ab"})
require.Nilf(t, err, "%v, could not get emoji", err)
require.Len(t, received, 0, "got incorrect emoji")
require.Empty(t, received, "got incorrect emoji")
})
t.Run("multiple emojis with nonexistent names", func(t *testing.T) {

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

@@ -395,7 +395,7 @@ func testFileInfoDeleteForPost(t *testing.T, ss store.Store) {
infos, err = ss.FileInfo().GetForPost(postId, true, false, false)
require.Nil(t, err)
assert.Len(t, infos, 0)
assert.Empty(t, infos)
}
func testFileInfoPermanentDelete(t *testing.T, ss store.Store) {

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

@@ -1107,7 +1107,7 @@ func testPendingAutoAddTeamMembers(t *testing.T, ss store.Store) {
// Time after syncable was created
teamMembers, err = ss.Group().TeamMembersToAdd(syncable.CreateAt + 1)
require.Nil(t, err)
require.Len(t, teamMembers, 0)
require.Empty(t, teamMembers)
// Delete and restore GroupMember should return result
_, err = ss.Group().DeleteMember(group.Id, user.Id)
@@ -1133,7 +1133,7 @@ func testPendingAutoAddTeamMembers(t *testing.T, ss store.Store) {
// Time after syncable was updated
teamMembers, err = ss.Group().TeamMembersToAdd(syncable.UpdateAt + 1)
require.Nil(t, err)
require.Len(t, teamMembers, 0)
require.Empty(t, teamMembers)
// Only includes if auto-add
syncable.AutoAdd = false
@@ -1141,7 +1141,7 @@ func testPendingAutoAddTeamMembers(t *testing.T, ss store.Store) {
require.Nil(t, err)
teamMembers, err = ss.Group().TeamMembersToAdd(0)
require.Nil(t, err)
require.Len(t, teamMembers, 0)
require.Empty(t, teamMembers)
// reset state of syncable and verify
_, err = ss.Group().UpdateGroupSyncable(&pristineSyncable)
@@ -1155,7 +1155,7 @@ func testPendingAutoAddTeamMembers(t *testing.T, ss store.Store) {
require.Nil(t, err)
teamMembers, err = ss.Group().TeamMembersToAdd(0)
require.Nil(t, err)
require.Len(t, teamMembers, 0)
require.Empty(t, teamMembers)
// reset state of group and verify
group.DeleteAt = 0
@@ -1171,7 +1171,7 @@ func testPendingAutoAddTeamMembers(t *testing.T, ss store.Store) {
require.Nil(t, err)
teamMembers, err = ss.Group().TeamMembersToAdd(0)
require.Nil(t, err)
require.Len(t, teamMembers, 0)
require.Empty(t, teamMembers)
// reset state of team and verify
team.DeleteAt = 0
@@ -1186,7 +1186,7 @@ func testPendingAutoAddTeamMembers(t *testing.T, ss store.Store) {
require.Nil(t, err)
teamMembers, err = ss.Group().TeamMembersToAdd(0)
require.Nil(t, err)
require.Len(t, teamMembers, 0)
require.Empty(t, teamMembers)
// reset GroupTeam and verify
_, err = ss.Group().UpdateGroupSyncable(&pristineSyncable)
@@ -1200,7 +1200,7 @@ func testPendingAutoAddTeamMembers(t *testing.T, ss store.Store) {
require.Nil(t, err)
teamMembers, err = ss.Group().TeamMembersToAdd(0)
require.Nil(t, err)
require.Len(t, teamMembers, 0)
require.Empty(t, teamMembers)
// restore group member and verify
_, err = ss.Group().UpsertMember(group.Id, user.Id)
@@ -1217,7 +1217,7 @@ func testPendingAutoAddTeamMembers(t *testing.T, ss store.Store) {
require.Nil(t, err)
teamMembers, err = ss.Group().TeamMembersToAdd(0)
require.Nil(t, err)
require.Len(t, teamMembers, 0)
require.Empty(t, teamMembers)
}
func testPendingAutoAddChannelMembers(t *testing.T, ss store.Store) {
@@ -1266,7 +1266,7 @@ func testPendingAutoAddChannelMembers(t *testing.T, ss store.Store) {
// Time after syncable was created
channelMembers, err = ss.Group().ChannelMembersToAdd(syncable.CreateAt + 1)
require.Nil(t, err)
require.Len(t, channelMembers, 0)
require.Empty(t, channelMembers)
// Delete and restore GroupMember should return result
_, err = ss.Group().DeleteMember(group.Id, user.Id)
@@ -1292,7 +1292,7 @@ func testPendingAutoAddChannelMembers(t *testing.T, ss store.Store) {
// Time after syncable was updated
channelMembers, err = ss.Group().ChannelMembersToAdd(syncable.UpdateAt + 1)
require.Nil(t, err)
require.Len(t, channelMembers, 0)
require.Empty(t, channelMembers)
// Only includes if auto-add
syncable.AutoAdd = false
@@ -1300,7 +1300,7 @@ func testPendingAutoAddChannelMembers(t *testing.T, ss store.Store) {
require.Nil(t, err)
channelMembers, err = ss.Group().ChannelMembersToAdd(0)
require.Nil(t, err)
require.Len(t, channelMembers, 0)
require.Empty(t, channelMembers)
// reset state of syncable and verify
_, err = ss.Group().UpdateGroupSyncable(&pristineSyncable)
@@ -1314,7 +1314,7 @@ func testPendingAutoAddChannelMembers(t *testing.T, ss store.Store) {
require.Nil(t, err)
channelMembers, err = ss.Group().ChannelMembersToAdd(0)
require.Nil(t, err)
require.Len(t, channelMembers, 0)
require.Empty(t, channelMembers)
// reset state of group and verify
group.DeleteAt = 0
@@ -1329,7 +1329,7 @@ func testPendingAutoAddChannelMembers(t *testing.T, ss store.Store) {
require.Nil(t, err)
channelMembers, err = ss.Group().ChannelMembersToAdd(0)
require.Nil(t, err)
require.Len(t, channelMembers, 0)
require.Empty(t, channelMembers)
// reset state of channel and verify
channel.DeleteAt = 0
@@ -1344,7 +1344,7 @@ func testPendingAutoAddChannelMembers(t *testing.T, ss store.Store) {
require.Nil(t, err)
channelMembers, err = ss.Group().ChannelMembersToAdd(0)
require.Nil(t, err)
require.Len(t, channelMembers, 0)
require.Empty(t, channelMembers)
// reset GroupChannel and verify
_, err = ss.Group().UpdateGroupSyncable(&pristineSyncable)
@@ -1358,7 +1358,7 @@ func testPendingAutoAddChannelMembers(t *testing.T, ss store.Store) {
require.Nil(t, err)
channelMembers, err = ss.Group().ChannelMembersToAdd(0)
require.Nil(t, err)
require.Len(t, channelMembers, 0)
require.Empty(t, channelMembers)
// restore group member and verify
_, err = ss.Group().UpsertMember(group.Id, user.Id)
@@ -1372,14 +1372,14 @@ func testPendingAutoAddChannelMembers(t *testing.T, ss store.Store) {
require.Nil(t, err)
channelMembers, err = ss.Group().ChannelMembersToAdd(0)
require.Nil(t, err)
require.Len(t, channelMembers, 0)
require.Empty(t, channelMembers)
// Leaving Channel (ChannelMemberHistory) should still not return result
err = ss.ChannelMemberHistory().LogLeaveEvent(user.Id, channel.Id, model.GetMillis())
require.Nil(t, err)
channelMembers, err = ss.Group().ChannelMembersToAdd(0)
require.Nil(t, err)
require.Len(t, channelMembers, 0)
require.Empty(t, channelMembers)
// Purging ChannelMemberHistory re-returns the result
_, err = ss.ChannelMemberHistory().PermanentDeleteBatch(model.GetMillis()+1, 100)

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

@@ -71,7 +71,7 @@ func testOAuthStoreGetApp(t *testing.T, ss store.Store) {
// Lets try and get the app from a user that hasn't created any apps
apps, err := ss.OAuth().GetAppByUser("fake0123456789abcderfgret1", 0, 1000)
require.Nil(t, err)
assert.Len(t, apps, 0, "Should have failed. Fake user hasn't created any apps")
assert.Empty(t, apps, "Should have failed. Fake user hasn't created any apps")
_, err = ss.OAuth().GetAppByUser(a1.CreatorId, 0, 1000)
require.Nil(t, err)
@@ -294,7 +294,7 @@ func testOAuthGetAuthorizedApps(t *testing.T, ss store.Store) {
// Lets try and get an Authorized app for a user who hasn't authorized it
apps, err := ss.OAuth().GetAuthorizedApps("fake0123456789abcderfgret1", 0, 1000)
require.Nil(t, err)
assert.Len(t, apps, 0, "Should have failed. Fake user hasn't authorized the app")
assert.Empty(t, apps, "Should have failed. Fake user hasn't authorized the app")
// allow the app
p := model.Preference{}

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

@@ -1118,7 +1118,7 @@ func testPostStoreGetPostsSince(t *testing.T, ss store.Store) {
assert.Nil(t, err)
assert.Equal(t, []string{}, postList.Order)
assert.Len(t, postList.Posts, 0)
assert.Empty(t, postList.Posts)
})
t.Run("should not cache a timestamp of 0 when nothing has changed", func(t *testing.T) {

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

@@ -251,7 +251,7 @@ func testPreferenceDelete(t *testing.T, ss store.Store) {
require.Nil(t, err)
preferences, err = ss.Preference().GetAll(preference.UserId)
require.Nil(t, err)
assert.Len(t, preferences, 0, "should've returned no preferences")
assert.Empty(t, preferences, "should've returned no preferences")
}
func testPreferenceDeleteCategory(t *testing.T, ss store.Store) {
@@ -284,7 +284,7 @@ func testPreferenceDeleteCategory(t *testing.T, ss store.Store) {
preferences, err = ss.Preference().GetAll(userId)
require.Nil(t, err)
assert.Len(t, preferences, 0, "should've returned no preferences")
assert.Empty(t, preferences, "should've returned no preferences")
}
func testPreferenceDeleteCategoryAndName(t *testing.T, ss store.Store) {
@@ -323,11 +323,11 @@ func testPreferenceDeleteCategoryAndName(t *testing.T, ss store.Store) {
preferences, err = ss.Preference().GetAll(userId)
require.Nil(t, err)
assert.Len(t, preferences, 0, "should've returned no preference")
assert.Empty(t, preferences, "should've returned no preference")
preferences, err = ss.Preference().GetAll(userId2)
require.Nil(t, err)
assert.Len(t, preferences, 0, "should've returned no preference")
assert.Empty(t, preferences, "should've returned no preference")
}
func testPreferenceCleanupFlagsBatch(t *testing.T, ss store.Store) {

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

@@ -125,7 +125,7 @@ func testReactionDelete(t *testing.T, ss store.Store) {
reactions, rErr := ss.Reaction().GetForPost(post.Id, false)
require.Nil(t, rErr)
assert.Len(t, reactions, 0, "should've deleted reaction")
assert.Empty(t, reactions, "should've deleted reaction")
postList, err := ss.Post().Get(post.Id, false)
require.Nil(t, err)
@@ -285,7 +285,7 @@ func testReactionDeleteAllWithEmojiName(t *testing.T, ss store.Store) {
returned, err = ss.Reaction().GetForPost(post3.Id, false)
require.Nil(t, err)
assert.Len(t, returned, 0, "should've only removed reactions with emoji name")
assert.Empty(t, returned, "should've only removed reactions with emoji name")
// check that the posts are updated
postList, err := ss.Post().Get(post.Id, false)

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

@@ -263,7 +263,7 @@ func testRoleStoreGetByNames(t *testing.T, ss store.Store) {
n5 := []string{model.NewId(), model.NewId()}
roles5, err := ss.Role().GetByNames(n5)
assert.Nil(t, err)
assert.Len(t, roles5, 0)
assert.Empty(t, roles5)
// Get one valid one and one invalid one.
n6 := []string{r1.Name, model.NewId()}
@@ -354,5 +354,5 @@ func testRoleStorePermanentDeleteAll(t *testing.T, ss store.Store) {
roles, err = ss.Role().GetByNames([]string{r1.Name, r2.Name})
assert.Nil(t, err)
assert.Len(t, roles, 0)
assert.Empty(t, roles)
}

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

@@ -484,5 +484,5 @@ func testSchemeStorePermanentDeleteAll(t *testing.T, ss store.Store) {
schemes, err := ss.Scheme().GetAllPage("", 0, 100000)
assert.Nil(t, err)
assert.Len(t, schemes, 0)
assert.Empty(t, schemes)
}

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

@@ -169,7 +169,7 @@ func testSessionRemoveToken(t *testing.T, ss store.Store) {
data, err := ss.Session().GetSessions(s1.UserId)
require.Nil(t, err)
require.Len(t, data, 0, "should match len")
require.Empty(t, data, "should match len")
}
func testSessionUpdateDeviceId(t *testing.T, ss store.Store) {

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

@@ -848,7 +848,7 @@ func testTeamMembers(t *testing.T, ss store.Store) {
ms, err = ss.Team().GetMembers(teamId1, 0, 100, nil)
require.Nil(t, err)
require.Len(t, ms, 0)
require.Empty(t, ms)
uid := model.NewId()
m4 := &model.TeamMember{TeamId: teamId1, UserId: uid}
@@ -867,7 +867,7 @@ func testTeamMembers(t *testing.T, ss store.Store) {
ms, err = ss.Team().GetTeamsForUser(m1.UserId)
require.Nil(t, err)
require.Len(t, ms, 0)
require.Empty(t, ms)
}
func testTeamMembersWithPagination(t *testing.T, ss store.Store) {
@@ -924,7 +924,7 @@ func testTeamMembersWithPagination(t *testing.T, ss store.Store) {
result, err = ss.Team().GetTeamsForUserWithPagination(uid, 1, 1)
require.Nil(t, err)
require.Len(t, result, 0)
require.Empty(t, result)
}
func testSaveTeamMemberMaxMembers(t *testing.T, ss store.Store) {
@@ -1340,12 +1340,12 @@ func testGetTeamsByScheme(t *testing.T, ss store.Store) {
// Get the teams by a valid Scheme ID where there aren't any matching Teams.
d, err = ss.Team().GetTeamsByScheme(s2.Id, 0, 100)
assert.Nil(t, err)
assert.Len(t, d, 0)
assert.Empty(t, d)
// Get the teams by an invalid Scheme ID.
d, err = ss.Team().GetTeamsByScheme(model.NewId(), 0, 100)
assert.Nil(t, err)
assert.Len(t, d, 0)
assert.Empty(t, d)
}
func testTeamStoreMigrateTeamMembers(t *testing.T, ss store.Store) {

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

@@ -159,7 +159,7 @@ func testWebhookStoreGetIncomingByTeam(t *testing.T, ss store.Store) {
hooks, err = ss.Webhook().GetIncomingByTeam("123", 0, 100)
require.Nil(t, err)
require.Len(t, hooks, 0, "no webhooks should have returned")
require.Empty(t, hooks, "no webhooks should have returned")
}
func TestWebhookStoreGetIncomingByTeamByUser(t *testing.T, ss store.Store) {
@@ -206,7 +206,7 @@ func TestWebhookStoreGetIncomingByChannel(t *testing.T, ss store.Store) {
webhooks, err = ss.Webhook().GetIncomingByChannel("123")
require.Nil(t, err)
require.Len(t, webhooks, 0, "no webhooks should have returned")
require.Empty(t, webhooks, "no webhooks should have returned")
}
func testWebhookStoreDeleteIncoming(t *testing.T, ss store.Store) {
@@ -387,7 +387,7 @@ func testWebhookStoreGetOutgoingByChannel(t *testing.T, ss store.Store) {
result, err := ss.Webhook().GetOutgoingByChannel("123", -1, -1)
require.Nil(t, err)
require.Len(t, result, 0, "no webhooks should have returned")
require.Empty(t, result, "no webhooks should have returned")
}
func testWebhookStoreGetOutgoingByChannelByUser(t *testing.T, ss store.Store) {
@@ -444,7 +444,7 @@ func testWebhookStoreGetOutgoingByTeam(t *testing.T, ss store.Store) {
result, err := ss.Webhook().GetOutgoingByTeam("123", -1, -1)
require.Nil(t, err)
require.Len(t, result, 0, "no webhooks should have returned")
require.Empty(t, result, "no webhooks should have returned")
}
func testWebhookStoreGetOutgoingByTeamByUser(t *testing.T, ss store.Store) {

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

@@ -517,7 +517,7 @@ func TestMergeWithSlices(t *testing.T) {
// of course this won't change merged, even if it did copy... but just in case.
m2 = append(m2, "test")
assert.Len(t, m2, 1)
assert.Len(t, merged, 0)
assert.Empty(t, merged)
})
t.Run("slice is not copied. change in patch will not affect merged", func(t *testing.T) {

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

@@ -23,7 +23,7 @@ func TestStringArrayIntersection(t *testing.T) {
"def",
}
assert.Len(t, StringArrayIntersection(a, b), 0)
assert.Empty(t, StringArrayIntersection(a, b))
assert.Len(t, StringArrayIntersection(a, c), 1)
}