Fix shadowed variables in app package: Part 3 of 3 (#10002)

Этот коммит содержится в:
Hanzei
2019-01-25 17:38:16 +01:00
коммит произвёл GitHub
родитель 954112102e
Коммит 16a8db2969
3 изменённых файлов: 122 добавлений и 179 удалений

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

@@ -57,9 +57,8 @@ func TestPermanentDeleteChannel(t *testing.T) {
t.Fatal("unable to get new outgoing webhook")
}
if err := th.App.PermanentDeleteChannel(channel); err != nil {
t.Fatal(err.Error())
}
err = th.App.PermanentDeleteChannel(channel)
require.Nil(t, err)
if incoming, err = th.App.GetIncomingWebhook(incoming.Id); incoming != nil || err == nil {
t.Error("incoming webhook wasn't deleted")
@@ -790,7 +789,8 @@ func TestGetPublicChannelsForTeam(t *testing.T) {
Type: model.CHANNEL_OPEN,
TeamId: team.Id,
}
rchannel, err := th.App.CreateChannel(&channel, false)
var rchannel *model.Channel
rchannel, err = th.App.CreateChannel(&channel, false)
require.Nil(t, err)
require.NotNil(t, rchannel)
defer th.App.PermanentDeleteChannel(rchannel)

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

@@ -805,9 +805,8 @@ func TestImportImportUser(t *testing.T) {
},
},
}
if err := th.App.ImportUser(&data, true); err == nil {
t.Fatalf("Should have failed.")
}
err = th.App.ImportUser(&data, true)
assert.NotNil(t, err)
// Test with an unknown team name & invalid channel membership in dry-run mode.
data.Teams = &[]UserTeamImportData{
@@ -820,9 +819,8 @@ func TestImportImportUser(t *testing.T) {
},
},
}
if err := th.App.ImportUser(&data, true); err == nil {
t.Fatalf("Should have failed.")
}
err = th.App.ImportUser(&data, true)
assert.NotNil(t, err)
// Test with a valid team & invalid channel membership in dry-run mode.
data.Teams = &[]UserTeamImportData{
@@ -835,9 +833,8 @@ func TestImportImportUser(t *testing.T) {
},
},
}
if err := th.App.ImportUser(&data, true); err == nil {
t.Fatalf("Should have failed.")
}
err = th.App.ImportUser(&data, true)
assert.NotNil(t, err)
// Test with a valid team & unknown channel name in dry-run mode.
data.Teams = &[]UserTeamImportData{
@@ -850,9 +847,8 @@ func TestImportImportUser(t *testing.T) {
},
},
}
if err := th.App.ImportUser(&data, true); err != nil {
t.Fatalf("Should have succeeded.")
}
err = th.App.ImportUser(&data, true)
assert.Nil(t, err)
// Test with a valid team & valid channel name in dry-run mode.
data.Teams = &[]UserTeamImportData{
@@ -865,22 +861,17 @@ func TestImportImportUser(t *testing.T) {
},
},
}
if err := th.App.ImportUser(&data, true); err != nil {
t.Fatalf("Should have succeeded.")
}
err = th.App.ImportUser(&data, true)
assert.Nil(t, err)
// Check no new member objects were created because dry run mode.
if tmc, err := th.App.GetTeamMembers(team.Id, 0, 1000); err != nil {
t.Fatalf("Failed to get Team Member Count")
} else if len(tmc) != teamMemberCount {
t.Fatalf("Number of team members not as expected")
}
tmc, err := th.App.GetTeamMembers(team.Id, 0, 1000)
require.Nil(t, err, "Failed to get Team Member Count")
require.Len(t, tmc, teamMemberCount, "Number of team members not as expected")
if cmc, err := th.App.GetChannelMemberCount(channel.Id); err != nil {
t.Fatalf("Failed to get Channel Member Count")
} else if cmc != channelMemberCount {
t.Fatalf("Number of channel members not as expected")
}
cmc, err := th.App.GetChannelMemberCount(channel.Id)
require.Nil(t, err, "Failed to get Channel Member Count")
require.Equal(t, channelMemberCount, cmc, "Number of channel members not as expected")
// Test with an invalid team & channel membership in apply mode.
data.Teams = &[]UserTeamImportData{
@@ -893,9 +884,8 @@ func TestImportImportUser(t *testing.T) {
},
},
}
if err := th.App.ImportUser(&data, false); err == nil {
t.Fatalf("Should have failed.")
}
err = th.App.ImportUser(&data, false)
assert.NotNil(t, err)
// Test with an unknown team name & invalid channel membership in apply mode.
data.Teams = &[]UserTeamImportData{
@@ -908,9 +898,8 @@ func TestImportImportUser(t *testing.T) {
},
},
}
if err := th.App.ImportUser(&data, false); err == nil {
t.Fatalf("Should have failed.")
}
err = th.App.ImportUser(&data, false)
assert.NotNil(t, err)
// Test with a valid team & invalid channel membership in apply mode.
data.Teams = &[]UserTeamImportData{
@@ -923,22 +912,17 @@ func TestImportImportUser(t *testing.T) {
},
},
}
if err := th.App.ImportUser(&data, false); err == nil {
t.Fatalf("Should have failed.")
}
err = th.App.ImportUser(&data, false)
assert.NotNil(t, err)
// Check no new member objects were created because all tests should have failed so far.
if tmc, err := th.App.GetTeamMembers(team.Id, 0, 1000); err != nil {
t.Fatalf("Failed to get Team Member Count")
} else if len(tmc) != teamMemberCount {
t.Fatalf("Number of team members not as expected")
}
tmc, err = th.App.GetTeamMembers(team.Id, 0, 1000)
require.Nil(t, err, "Failed to get Team Member Count")
require.Len(t, tmc, teamMemberCount)
if cmc, err := th.App.GetChannelMemberCount(channel.Id); err != nil {
t.Fatalf("Failed to get Channel Member Count")
} else if cmc != channelMemberCount {
t.Fatalf("Number of channel members not as expected")
}
cmc, err = th.App.GetChannelMemberCount(channel.Id)
require.Nil(t, err, "Failed to get Channel Member Count")
require.Equal(t, channelMemberCount, cmc)
// Test with a valid team & unknown channel name in apply mode.
data.Teams = &[]UserTeamImportData{
@@ -951,33 +935,27 @@ func TestImportImportUser(t *testing.T) {
},
},
}
if err := th.App.ImportUser(&data, false); err == nil {
t.Fatalf("Should have failed.")
}
err = th.App.ImportUser(&data, false)
assert.NotNil(t, err)
// Check only new team member object created because dry run mode.
if tmc, err := th.App.GetTeamMembers(team.Id, 0, 1000); err != nil {
t.Fatalf("Failed to get Team Member Count")
} else if len(tmc) != teamMemberCount+1 {
t.Fatalf("Number of team members not as expected")
}
tmc, err = th.App.GetTeamMembers(team.Id, 0, 1000)
require.Nil(t, err, "Failed to get Team Member Count")
require.Len(t, tmc, teamMemberCount+1)
if cmc, err := th.App.GetChannelMemberCount(channel.Id); err != nil {
t.Fatalf("Failed to get Channel Member Count")
} else if cmc != channelMemberCount {
t.Fatalf("Number of channel members not as expected")
}
cmc, err = th.App.GetChannelMemberCount(channel.Id)
require.Nil(t, err, "Failed to get Channel Member Count")
require.Equal(t, channelMemberCount, cmc)
// Check team member properties.
user, err := th.App.GetUserByUsername(username)
if err != nil {
t.Fatalf("Failed to get user from database.")
}
if teamMember, err := th.App.GetTeamMember(team.Id, user.Id); err != nil {
t.Fatalf("Failed to get team member from database.")
} else if teamMember.Roles != "team_user" {
t.Fatalf("Team member properties not as expected")
}
teamMember, err := th.App.GetTeamMember(team.Id, user.Id)
require.Nil(t, err, "Failed to get team member from database.")
require.Equal(t, "team_user", teamMember.Roles)
// Test with a valid team & valid channel name in apply mode.
data.Teams = &[]UserTeamImportData{
@@ -990,29 +968,25 @@ func TestImportImportUser(t *testing.T) {
},
},
}
if err := th.App.ImportUser(&data, false); err != nil {
t.Fatalf("Should have succeeded.")
}
err = th.App.ImportUser(&data, false)
assert.Nil(t, err)
// Check only new channel member object created because dry run mode.
if tmc, err := th.App.GetTeamMembers(team.Id, 0, 1000); err != nil {
t.Fatalf("Failed to get Team Member Count")
} else if len(tmc) != teamMemberCount+1 {
t.Fatalf("Number of team members not as expected")
}
tmc, err = th.App.GetTeamMembers(team.Id, 0, 1000)
require.Nil(t, err, "Failed to get Team Member Count")
require.Len(t, tmc, teamMemberCount+1, "Number of team members not as expected")
if cmc, err := th.App.GetChannelMemberCount(channel.Id); err != nil {
t.Fatalf("Failed to get Channel Member Count")
} else if cmc != channelMemberCount+1 {
t.Fatalf("Number of channel members not as expected")
}
cmc, err = th.App.GetChannelMemberCount(channel.Id)
require.Nil(t, err, "Failed to get Channel Member Count")
require.Equal(t, channelMemberCount+1, cmc, "Number of channel members not as expected")
// Check channel member properties.
if channelMember, err := th.App.GetChannelMember(channel.Id, user.Id); err != nil {
t.Fatalf("Failed to get channel member from database.")
} else if channelMember.Roles != "channel_user" || channelMember.NotifyProps[model.DESKTOP_NOTIFY_PROP] != "default" || channelMember.NotifyProps[model.PUSH_NOTIFY_PROP] != "default" || channelMember.NotifyProps[model.MARK_UNREAD_NOTIFY_PROP] != "all" {
t.Fatalf("Channel member properties not as expected")
}
channelMember, err := th.App.GetChannelMember(channel.Id, user.Id)
require.Nil(t, err, "Failed to get channel member from database.")
assert.Equal(t, "channel_user", channelMember.Roles)
assert.Equal(t, "default", channelMember.NotifyProps[model.DESKTOP_NOTIFY_PROP])
assert.Equal(t, "default", channelMember.NotifyProps[model.PUSH_NOTIFY_PROP])
assert.Equal(t, "all", channelMember.NotifyProps[model.MARK_UNREAD_NOTIFY_PROP])
// Test with the properties of the team and channel membership changed.
data.Teams = &[]UserTeamImportData{
@@ -1034,38 +1008,32 @@ func TestImportImportUser(t *testing.T) {
},
},
}
if err := th.App.ImportUser(&data, false); err != nil {
t.Fatalf("Should have succeeded.")
}
err = th.App.ImportUser(&data, false)
assert.Nil(t, err)
// Check both member properties.
if teamMember, err := th.App.GetTeamMember(team.Id, user.Id); err != nil {
t.Fatalf("Failed to get team member from database.")
} else if teamMember.Roles != "team_user team_admin" {
t.Fatalf("Team member properties not as expected: %v", teamMember.Roles)
}
teamMember, err = th.App.GetTeamMember(team.Id, user.Id)
require.Nil(t, err, "Failed to get team member from database.")
require.Equal(t, "team_user team_admin", teamMember.Roles)
if channelMember, err := th.App.GetChannelMember(channel.Id, user.Id); err != nil {
t.Fatalf("Failed to get channel member Desktop from database.")
} else if channelMember.Roles != "channel_user channel_admin" || channelMember.NotifyProps[model.DESKTOP_NOTIFY_PROP] != model.USER_NOTIFY_MENTION || channelMember.NotifyProps[model.PUSH_NOTIFY_PROP] != model.USER_NOTIFY_MENTION || channelMember.NotifyProps[model.MARK_UNREAD_NOTIFY_PROP] != model.USER_NOTIFY_MENTION {
t.Fatalf("Channel member properties not as expected")
}
channelMember, err = th.App.GetChannelMember(channel.Id, user.Id)
require.Nil(t, err, "Failed to get channel member Desktop from database.")
assert.Equal(t, "channel_user channel_admin", channelMember.Roles)
assert.Equal(t, model.USER_NOTIFY_MENTION, channelMember.NotifyProps[model.DESKTOP_NOTIFY_PROP])
assert.Equal(t, model.USER_NOTIFY_MENTION, channelMember.NotifyProps[model.PUSH_NOTIFY_PROP])
assert.Equal(t, model.USER_NOTIFY_MENTION, channelMember.NotifyProps[model.MARK_UNREAD_NOTIFY_PROP])
checkPreference(t, th.App, user.Id, model.PREFERENCE_CATEGORY_FAVORITE_CHANNEL, channel.Id, "true")
checkPreference(t, th.App, user.Id, model.PREFERENCE_CATEGORY_THEME, team.Id, *(*data.Teams)[0].Theme)
// No more new member objects.
if tmc, err := th.App.GetTeamMembers(team.Id, 0, 1000); err != nil {
t.Fatalf("Failed to get Team Member Count")
} else if len(tmc) != teamMemberCount+1 {
t.Fatalf("Number of team members not as expected")
}
tmc, err = th.App.GetTeamMembers(team.Id, 0, 1000)
require.Nil(t, err, "Failed to get Team Member Count")
require.Len(t, tmc, teamMemberCount+1, "Number of team members not as expected")
if cmc, err := th.App.GetChannelMemberCount(channel.Id); err != nil {
t.Fatalf("Failed to get Channel Member Count")
} else if cmc != channelMemberCount+1 {
t.Fatalf("Number of channel members not as expected")
}
cmc, err = th.App.GetChannelMemberCount(channel.Id)
require.Nil(t, err, "Failed to get Channel Member Count")
require.Equal(t, channelMemberCount+1, cmc, "Number of channel members not as expected")
// Add a user with some preferences.
username = model.NewId()
@@ -1083,9 +1051,8 @@ func TestImportImportUser(t *testing.T) {
ShowUnreadSection: ptrStr("true"),
EmailInterval: ptrStr("immediately"),
}
if err := th.App.ImportUser(&data, false); err != nil {
t.Fatalf("Should have succeeded.")
}
err = th.App.ImportUser(&data, false)
assert.Nil(t, err)
// Check their values.
user, err = th.App.GetUserByUsername(username)
@@ -1116,9 +1083,8 @@ func TestImportImportUser(t *testing.T) {
TutorialStep: ptrStr("2"),
EmailInterval: ptrStr("hour"),
}
if err := th.App.ImportUser(&data, false); err != nil {
t.Fatalf("Should have succeeded.")
}
err = th.App.ImportUser(&data, false)
assert.Nil(t, err)
// Check their values again.
checkPreference(t, th.App, user.Id, model.PREFERENCE_CATEGORY_THEME, "", *data.Theme)
@@ -1140,9 +1106,8 @@ func TestImportImportUser(t *testing.T) {
CommentsTrigger: ptrStr(model.COMMENTS_NOTIFY_ROOT),
MentionKeys: ptrStr("valid,misc"),
}
if err := th.App.ImportUser(&data, false); err != nil {
t.Fatalf("Should have succeeded.")
}
err = th.App.ImportUser(&data, false)
assert.Nil(t, err)
user, err = th.App.GetUserByUsername(username)
if err != nil {
@@ -1169,9 +1134,8 @@ func TestImportImportUser(t *testing.T) {
CommentsTrigger: ptrStr(model.COMMENTS_NOTIFY_ANY),
MentionKeys: ptrStr("misc"),
}
if err := th.App.ImportUser(&data, false); err != nil {
t.Fatalf("Should have succeeded.")
}
err = th.App.ImportUser(&data, false)
assert.Nil(t, err)
user, err = th.App.GetUserByUsername(username)
if err != nil {
@@ -1204,9 +1168,8 @@ func TestImportImportUser(t *testing.T) {
MentionKeys: ptrStr("misc"),
}
if err := th.App.ImportUser(&data, false); err != nil {
t.Fatalf("Should have succeeded.")
}
err = th.App.ImportUser(&data, false)
assert.Nil(t, err)
user, err = th.App.GetUserByUsername(username)
if err != nil {
@@ -1256,9 +1219,8 @@ func TestImportImportUser(t *testing.T) {
Description: ptrStr("description"),
}
if err := th.App.ImportScheme(teamSchemeData, false); err != nil {
t.Fatalf("Should have succeeded.")
}
err = th.App.ImportScheme(teamSchemeData, false)
assert.Nil(t, err)
var teamScheme *model.Scheme
if res := <-th.App.Srv.Store.Scheme().GetByName(*teamSchemeData.Name); res.Err != nil {
@@ -1275,9 +1237,8 @@ func TestImportImportUser(t *testing.T) {
AllowOpenInvite: ptrBool(true),
Scheme: &teamScheme.Name,
}
if err := th.App.ImportTeam(teamData, false); err != nil {
t.Fatalf("Import should have succeeded: %v", err.Error())
}
err = th.App.ImportTeam(teamData, false)
assert.Nil(t, err)
team, err = th.App.GetTeamByName(teamName)
if err != nil {
t.Fatalf("Failed to get team from database.")
@@ -1291,9 +1252,8 @@ func TestImportImportUser(t *testing.T) {
Header: ptrStr("Channe Header"),
Purpose: ptrStr("Channel Purpose"),
}
if err := th.App.ImportChannel(channelData, false); err != nil {
t.Fatalf("Import should have succeeded.")
}
err = th.App.ImportChannel(channelData, false)
assert.Nil(t, err)
channel, err = th.App.GetChannelByName(*channelData.Name, team.Id, false)
if err != nil {
t.Fatalf("Failed to get channel from database: %v", err.Error())
@@ -1316,16 +1276,15 @@ func TestImportImportUser(t *testing.T) {
},
},
}
if err := th.App.ImportUser(userData, false); err != nil {
t.Fatalf("Should have succeeded.")
}
err = th.App.ImportUser(userData, false)
assert.Nil(t, err)
user, err = th.App.GetUserByUsername(*userData.Username)
if err != nil {
t.Fatalf("Failed to get user from database.")
}
teamMember, err := th.App.GetTeamMember(team.Id, user.Id)
teamMember, err = th.App.GetTeamMember(team.Id, user.Id)
if err != nil {
t.Fatalf("Failed to get the team member")
}
@@ -1333,7 +1292,7 @@ func TestImportImportUser(t *testing.T) {
assert.True(t, teamMember.SchemeUser)
assert.Equal(t, "", teamMember.ExplicitRoles)
channelMember, err := th.App.GetChannelMember(channel.Id, user.Id)
channelMember, err = th.App.GetChannelMember(channel.Id, user.Id)
if err != nil {
t.Fatalf("Failed to get the channel member")
}
@@ -1356,7 +1315,6 @@ func TestImportUserDefaultNotifyProps(t *testing.T) {
Email: ptrStr("false"),
},
}
require.Nil(t, th.App.ImportUser(&data, false))
user, err := th.App.GetUserByUsername(username)
@@ -1436,9 +1394,8 @@ func TestImportImportPost(t *testing.T) {
Channel: &channelName,
User: &username,
}
if err := th.App.ImportPost(data, true); err == nil {
t.Fatalf("Expected error.")
}
err = th.App.ImportPost(data, true)
assert.NotNil(t, err)
AssertAllPostsCount(t, th.App, initialPostCount, 0, team.Id)
// Try adding a valid post in dry run mode.
@@ -1449,9 +1406,8 @@ func TestImportImportPost(t *testing.T) {
Message: ptrStr("Hello"),
CreateAt: ptrInt64(model.GetMillis()),
}
if err := th.App.ImportPost(data, true); err != nil {
t.Fatalf("Expected success.")
}
err = th.App.ImportPost(data, true)
assert.Nil(t, err)
AssertAllPostsCount(t, th.App, initialPostCount, 0, team.Id)
// Try adding an invalid post in apply mode.
@@ -1461,9 +1417,8 @@ func TestImportImportPost(t *testing.T) {
User: &username,
CreateAt: ptrInt64(model.GetMillis()),
}
if err := th.App.ImportPost(data, false); err == nil {
t.Fatalf("Expected error.")
}
err = th.App.ImportPost(data, false)
assert.NotNil(t, err)
AssertAllPostsCount(t, th.App, initialPostCount, 0, team.Id)
// Try adding a valid post with invalid team in apply mode.
@@ -1474,9 +1429,8 @@ func TestImportImportPost(t *testing.T) {
Message: ptrStr("Message"),
CreateAt: ptrInt64(model.GetMillis()),
}
if err := th.App.ImportPost(data, false); err == nil {
t.Fatalf("Expected error.")
}
err = th.App.ImportPost(data, false)
assert.NotNil(t, err)
AssertAllPostsCount(t, th.App, initialPostCount, 0, team.Id)
// Try adding a valid post with invalid channel in apply mode.
@@ -1487,9 +1441,8 @@ func TestImportImportPost(t *testing.T) {
Message: ptrStr("Message"),
CreateAt: ptrInt64(model.GetMillis()),
}
if err := th.App.ImportPost(data, false); err == nil {
t.Fatalf("Expected error.")
}
err = th.App.ImportPost(data, false)
assert.NotNil(t, err)
AssertAllPostsCount(t, th.App, initialPostCount, 0, team.Id)
// Try adding a valid post with invalid user in apply mode.
@@ -1500,9 +1453,8 @@ func TestImportImportPost(t *testing.T) {
Message: ptrStr("Message"),
CreateAt: ptrInt64(model.GetMillis()),
}
if err := th.App.ImportPost(data, false); err == nil {
t.Fatalf("Expected error.")
}
err = th.App.ImportPost(data, false)
assert.NotNil(t, err)
AssertAllPostsCount(t, th.App, initialPostCount, 0, team.Id)
// Try adding a valid post in apply mode.
@@ -1514,9 +1466,8 @@ func TestImportImportPost(t *testing.T) {
Message: ptrStr("Message"),
CreateAt: &time,
}
if err := th.App.ImportPost(data, false); err != nil {
t.Fatalf("Expected success.")
}
err = th.App.ImportPost(data, false)
assert.Nil(t, err)
AssertAllPostsCount(t, th.App, initialPostCount, 1, team.Id)
// Check the post values.
@@ -1541,9 +1492,8 @@ func TestImportImportPost(t *testing.T) {
Message: ptrStr("Message"),
CreateAt: &time,
}
if err := th.App.ImportPost(data, false); err != nil {
t.Fatalf("Expected success.")
}
err = th.App.ImportPost(data, false)
assert.Nil(t, err)
AssertAllPostsCount(t, th.App, initialPostCount, 1, team.Id)
// Check the post values.
@@ -1569,9 +1519,8 @@ func TestImportImportPost(t *testing.T) {
Message: ptrStr("Message"),
CreateAt: &newTime,
}
if err := th.App.ImportPost(data, false); err != nil {
t.Fatalf("Expected success.")
}
err = th.App.ImportPost(data, false)
assert.Nil(t, err)
AssertAllPostsCount(t, th.App, initialPostCount, 2, team.Id)
// Save the post with a different message.
@@ -1582,9 +1531,8 @@ func TestImportImportPost(t *testing.T) {
Message: ptrStr("Message 2"),
CreateAt: &time,
}
if err := th.App.ImportPost(data, false); err != nil {
t.Fatalf("Expected success.")
}
err = th.App.ImportPost(data, false)
assert.Nil(t, err)
AssertAllPostsCount(t, th.App, initialPostCount, 3, team.Id)
// Test with hashtags
@@ -1596,9 +1544,8 @@ func TestImportImportPost(t *testing.T) {
Message: ptrStr("Message 2 #hashtagmashupcity"),
CreateAt: &hashtagTime,
}
if err := th.App.ImportPost(data, false); err != nil {
t.Fatalf("Expected success.")
}
err = th.App.ImportPost(data, false)
assert.Nil(t, err)
AssertAllPostsCount(t, th.App, initialPostCount, 4, team.Id)
if result := <-th.App.Srv.Store.Post().GetPostsCreatedAt(channel.Id, hashtagTime); result.Err != nil {
@@ -1983,7 +1930,6 @@ func TestImportImportDirectChannel(t *testing.T) {
require.Nil(t, err)
checkPreference(t, th.App, th.BasicUser.Id, model.PREFERENCE_CATEGORY_FAVORITE_CHANNEL, channel.Id, "true")
checkPreference(t, th.App, th.BasicUser2.Id, model.PREFERENCE_CATEGORY_FAVORITE_CHANNEL, channel.Id, "true")
}
func TestImportImportDirectPost(t *testing.T) {
@@ -2008,10 +1954,9 @@ func TestImportImportDirectPost(t *testing.T) {
directChannel = channel
// Get the number of posts in the system.
var initialPostCount int64
result := <-th.App.Srv.Store.Post().AnalyticsPostCount("", false, false)
require.Nil(t, result.Err)
initialPostCount = result.Data.(int64)
initialPostCount := result.Data.(int64)
// Try adding an invalid post in dry run mode.
data := &DirectPostImportData{
@@ -2473,9 +2418,8 @@ func TestImportPostAndRepliesWithAttachments(t *testing.T) {
}},
}
if err := th.App.ImportPost(data, false); err != nil {
t.Fatalf("Expected success.")
}
err = th.App.ImportPost(data, false)
assert.Nil(t, err)
attachments := GetAttachments(user3.Id, th, t)
assert.Equal(t, len(attachments), 2)

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

@@ -339,9 +339,8 @@ func TestPermanentDeleteTeam(t *testing.T) {
t.Fatal("unable to get new command")
}
if err := th.App.PermanentDeleteTeam(team); err != nil {
t.Fatal(err.Error())
}
err = th.App.PermanentDeleteTeam(team)
require.Nil(t, err)
if command, err = th.App.GetCommand(command.Id); command != nil || err == nil {
t.Fatal("command wasn't deleted")