Merge branch 'master' into mark-as-unread
Этот коммит содержится в:
@@ -95,7 +95,7 @@ func (a *App) JoinDefaultChannels(teamId string, user *model.User, shouldBeAdmin
|
||||
|
||||
_, err = a.Srv.Store.Channel().SaveMember(cm)
|
||||
if histErr := a.Srv.Store.ChannelMemberHistory().LogJoinEvent(user.Id, channel.Id, model.GetMillis()); histErr != nil {
|
||||
mlog.Warn(fmt.Sprintf("Failed to update ChannelMemberHistory table %v", histErr))
|
||||
mlog.Warn("Failed to update ChannelMemberHistory table", mlog.Err(histErr))
|
||||
}
|
||||
|
||||
if *a.Config().ServiceSettings.ExperimentalEnableDefaultChannelLeaveJoinMessages {
|
||||
@@ -126,21 +126,21 @@ func (a *App) postJoinMessageForDefaultChannel(user *model.User, requestor *mode
|
||||
if channel.Name == model.DEFAULT_CHANNEL {
|
||||
if requestor == nil {
|
||||
if err := a.postJoinTeamMessage(user, channel); err != nil {
|
||||
mlog.Error(fmt.Sprint("Failed to post join/leave message", err))
|
||||
mlog.Error("Failed to post join/leave message", mlog.Err(err))
|
||||
}
|
||||
} else {
|
||||
if err := a.postAddToTeamMessage(requestor, user, channel, ""); err != nil {
|
||||
mlog.Error(fmt.Sprint("Failed to post join/leave message", err))
|
||||
mlog.Error("Failed to post join/leave message", mlog.Err(err))
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if requestor == nil {
|
||||
if err := a.postJoinChannelMessage(user, channel); err != nil {
|
||||
mlog.Error(fmt.Sprint("Failed to post join/leave message", err))
|
||||
mlog.Error("Failed to post join/leave message", mlog.Err(err))
|
||||
}
|
||||
} else {
|
||||
if err := a.PostAddToChannelMessage(requestor, user, channel, ""); err != nil {
|
||||
mlog.Error(fmt.Sprint("Failed to post join/leave message", err))
|
||||
mlog.Error("Failed to post join/leave message", mlog.Err(err))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -247,7 +247,7 @@ func (a *App) CreateChannel(channel *model.Channel, addMember bool) (*model.Chan
|
||||
return nil, err
|
||||
}
|
||||
if err := a.Srv.Store.ChannelMemberHistory().LogJoinEvent(channel.CreatorId, sc.Id, model.GetMillis()); err != nil {
|
||||
mlog.Warn(fmt.Sprintf("Failed to update ChannelMemberHistory table %v", err))
|
||||
mlog.Warn("Failed to update ChannelMemberHistory table", mlog.Err(err))
|
||||
}
|
||||
|
||||
a.InvalidateCacheForUser(channel.CreatorId)
|
||||
@@ -366,10 +366,10 @@ func (a *App) createDirectChannel(userId string, otherUserId string) (*model.Cha
|
||||
}
|
||||
|
||||
if err = a.Srv.Store.ChannelMemberHistory().LogJoinEvent(userId, channel.Id, model.GetMillis()); err != nil {
|
||||
mlog.Warn(fmt.Sprintf("Failed to update ChannelMemberHistory table %v", err))
|
||||
mlog.Warn("Failed to update ChannelMemberHistory table", mlog.Err(err))
|
||||
}
|
||||
if err = a.Srv.Store.ChannelMemberHistory().LogJoinEvent(otherUserId, channel.Id, model.GetMillis()); err != nil {
|
||||
mlog.Warn(fmt.Sprintf("Failed to update ChannelMemberHistory table %v", err))
|
||||
mlog.Warn("Failed to update ChannelMemberHistory table", mlog.Err(err))
|
||||
}
|
||||
|
||||
return channel, nil
|
||||
@@ -399,7 +399,7 @@ func (a *App) WaitForChannelMembership(channelId string, userId string) {
|
||||
}
|
||||
}
|
||||
|
||||
mlog.Error(fmt.Sprintf("WaitForChannelMembership giving up channelId=%v userId=%v", channelId, userId), mlog.String("user_id", userId))
|
||||
mlog.Error("WaitForChannelMembership giving up", mlog.String("channel_id", channelId), mlog.String("user_id", userId))
|
||||
}
|
||||
|
||||
func (a *App) CreateGroupChannel(userIds []string, creatorId string) (*model.Channel, *model.AppError) {
|
||||
@@ -477,7 +477,7 @@ func (a *App) createGroupChannel(userIds []string, creatorId string) (*model.Cha
|
||||
return nil, err
|
||||
}
|
||||
if err := a.Srv.Store.ChannelMemberHistory().LogJoinEvent(user.Id, channel.Id, model.GetMillis()); err != nil {
|
||||
mlog.Warn(fmt.Sprintf("Failed to update ChannelMemberHistory table %v", err))
|
||||
mlog.Warn("Failed to update ChannelMemberHistory table", mlog.Err(err))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -861,21 +861,21 @@ func (a *App) DeleteChannel(channel *model.Channel, userId string) *model.AppErr
|
||||
}
|
||||
|
||||
if _, err := a.CreatePost(post, channel, false); err != nil {
|
||||
mlog.Error(fmt.Sprintf("Failed to post archive message %v", err))
|
||||
mlog.Error("Failed to post archive message", mlog.Err(err))
|
||||
}
|
||||
}
|
||||
|
||||
now := model.GetMillis()
|
||||
for _, hook := range incomingHooks {
|
||||
if err := a.Srv.Store.Webhook().DeleteIncoming(hook.Id, now); err != nil {
|
||||
mlog.Error(fmt.Sprintf("Encountered error deleting incoming webhook, id=%v", hook.Id))
|
||||
mlog.Error("Encountered error deleting incoming webhook", mlog.String("hook_id", hook.Id), mlog.Err(err))
|
||||
}
|
||||
a.InvalidateCacheForWebhook(hook.Id)
|
||||
}
|
||||
|
||||
for _, hook := range outgoingHooks {
|
||||
if err := a.Srv.Store.Webhook().DeleteOutgoing(hook.Id, now); err != nil {
|
||||
mlog.Error(fmt.Sprintf("Encountered error deleting outgoing webhook, id=%v", hook.Id))
|
||||
mlog.Error("Encountered error deleting outgoing webhook", mlog.String("hook_id", hook.Id), mlog.Err(err))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -926,13 +926,13 @@ func (a *App) addUserToChannel(user *model.User, channel *model.Channel, teamMem
|
||||
SchemeUser: !user.IsGuest(),
|
||||
}
|
||||
if _, err = a.Srv.Store.Channel().SaveMember(newMember); err != nil {
|
||||
mlog.Error(fmt.Sprintf("Failed to add member user_id=%v channel_id=%v err=%v", user.Id, channel.Id, err), mlog.String("user_id", user.Id))
|
||||
mlog.Error("Failed to add member", mlog.String("user_id", user.Id), mlog.String("channel_id", channel.Id), mlog.Err(err))
|
||||
return nil, model.NewAppError("AddUserToChannel", "api.channel.add_user.to.channel.failed.app_error", nil, "", http.StatusInternalServerError)
|
||||
}
|
||||
a.WaitForChannelMembership(channel.Id, user.Id)
|
||||
|
||||
if err = a.Srv.Store.ChannelMemberHistory().LogJoinEvent(user.Id, channel.Id, model.GetMillis()); err != nil {
|
||||
mlog.Warn(fmt.Sprintf("Failed to update ChannelMemberHistory table %v", err))
|
||||
mlog.Warn("Failed to update ChannelMemberHistory table", mlog.Err(err))
|
||||
}
|
||||
|
||||
a.InvalidateCacheForUser(user.Id)
|
||||
@@ -1918,13 +1918,13 @@ func (a *App) MarkChannelsAsViewed(channelIds []string, userId string, currentSe
|
||||
for _, channelId := range channelIds {
|
||||
channel, errCh := a.Srv.Store.Channel().Get(channelId, true)
|
||||
if errCh != nil {
|
||||
mlog.Warn(fmt.Sprintf("Failed to get channel %v", errCh))
|
||||
mlog.Warn("Failed to get channel", mlog.Err(errCh))
|
||||
continue
|
||||
}
|
||||
|
||||
member, err := a.Srv.Store.Channel().GetMember(channelId, userId)
|
||||
if err != nil {
|
||||
mlog.Warn(fmt.Sprintf("Failed to get membership %v", err))
|
||||
mlog.Warn("Failed to get membership", mlog.Err(err))
|
||||
continue
|
||||
}
|
||||
|
||||
|
||||
@@ -487,6 +487,7 @@ func (a *App) trackConfig() {
|
||||
"isempty_group_filter": isDefault(*cfg.LdapSettings.GroupFilter, ""),
|
||||
"isdefault_group_display_name_attribute": isDefault(*cfg.LdapSettings.GroupDisplayNameAttribute, model.LDAP_SETTINGS_DEFAULT_GROUP_DISPLAY_NAME_ATTRIBUTE),
|
||||
"isdefault_group_id_attribute": isDefault(*cfg.LdapSettings.GroupIdAttribute, model.LDAP_SETTINGS_DEFAULT_GROUP_ID_ATTRIBUTE),
|
||||
"isempty_guest_filter": isDefault(*cfg.LdapSettings.GuestFilter, ""),
|
||||
})
|
||||
|
||||
a.SendDiagnostic(TRACK_CONFIG_COMPLIANCE, map[string]interface{}{
|
||||
|
||||
18
app/email.go
18
app/email.go
@@ -347,13 +347,13 @@ func (a *App) SendInviteEmails(team *model.Team, senderName string, senderUserId
|
||||
data := model.MapToJson(props)
|
||||
|
||||
if err := a.Srv.Store.Token().Save(token); err != nil {
|
||||
mlog.Error(fmt.Sprintf("Failed to send invite email successfully err=%v", err))
|
||||
mlog.Error("Failed to send invite email successfully ", mlog.Err(err))
|
||||
continue
|
||||
}
|
||||
bodyPage.Props["Link"] = fmt.Sprintf("%s/signup_user_complete/?d=%s&t=%s", siteURL, url.QueryEscape(data), url.QueryEscape(token.Token))
|
||||
|
||||
if err := a.SendMail(invite, subject, bodyPage.Render()); err != nil {
|
||||
mlog.Error(fmt.Sprintf("Failed to send invite email successfully err=%v", err))
|
||||
mlog.Error("Failed to send invite email successfully ", mlog.Err(err))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -435,24 +435,26 @@ func (a *App) SendGuestInviteEmails(team *model.Team, channels []*model.Channel,
|
||||
data := model.MapToJson(props)
|
||||
|
||||
if err := a.Srv.Store.Token().Save(token); err != nil {
|
||||
mlog.Error(fmt.Sprintf("Failed to send invite email successfully err=%v", err))
|
||||
mlog.Error("Failed to send invite email successfully ", mlog.Err(err))
|
||||
continue
|
||||
}
|
||||
bodyPage.Props["Link"] = fmt.Sprintf("%s/signup_user_complete/?d=%s&t=%s", siteURL, url.QueryEscape(data), url.QueryEscape(token.Token))
|
||||
|
||||
if !*a.Config().EmailSettings.SendEmailNotifications {
|
||||
mlog.Info(fmt.Sprintf("sending invitation to %v %v", invite, bodyPage.Props["Link"]))
|
||||
mlog.Info("sending invitation ", mlog.String("to", invite), mlog.String("link", bodyPage.Props["Link"].(string)))
|
||||
}
|
||||
|
||||
embeddedFiles := make(map[string]io.Reader)
|
||||
if senderProfileImage != nil {
|
||||
embeddedFiles = map[string]io.Reader{
|
||||
"user-avatar.png": bytes.NewReader(senderProfileImage),
|
||||
if message != "" {
|
||||
if senderProfileImage != nil {
|
||||
embeddedFiles = map[string]io.Reader{
|
||||
"user-avatar.png": bytes.NewReader(senderProfileImage),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if err := a.SendMailWithEmbeddedFiles(invite, subject, bodyPage.Render(), embeddedFiles); err != nil {
|
||||
mlog.Error(fmt.Sprintf("Failed to send invite email successfully err=%v", err))
|
||||
mlog.Error("Failed to send invite email successfully", mlog.Err(err))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ package app
|
||||
import (
|
||||
"net/http"
|
||||
"path/filepath"
|
||||
"runtime/debug"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
@@ -34,73 +33,43 @@ func ptrBool(b bool) *bool {
|
||||
}
|
||||
|
||||
func checkPreference(t *testing.T, a *App, userId string, category string, name string, value string) {
|
||||
if preferences, err := a.Srv.Store.Preference().GetCategory(userId, category); err != nil {
|
||||
debug.PrintStack()
|
||||
t.Fatalf("Failed to get preferences for user %v with category %v", userId, category)
|
||||
} else {
|
||||
found := false
|
||||
for _, preference := range preferences {
|
||||
if preference.Name == name {
|
||||
found = true
|
||||
if preference.Value != value {
|
||||
debug.PrintStack()
|
||||
t.Fatalf("Preference for user %v in category %v with name %v has value %v, expected %v", userId, category, name, preference.Value, value)
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
debug.PrintStack()
|
||||
t.Fatalf("Did not find preference for user %v in category %v with name %v", userId, category, name)
|
||||
preferences, err := a.Srv.Store.Preference().GetCategory(userId, category)
|
||||
require.Nilf(t, err, "Failed to get preferences for user %v with category %v", userId, category)
|
||||
found := false
|
||||
for _, preference := range preferences {
|
||||
if preference.Name == name {
|
||||
found = true
|
||||
require.Equal(t, preference.Value, value, "Preference for user %v in category %v with name %v has value %v, expected %v", userId, category, name, preference.Value, value)
|
||||
break
|
||||
}
|
||||
}
|
||||
require.Truef(t, found, "Did not find preference for user %v in category %v with name %v", userId, category, name)
|
||||
}
|
||||
|
||||
func checkNotifyProp(t *testing.T, user *model.User, key string, value string) {
|
||||
if actual, ok := user.NotifyProps[key]; !ok {
|
||||
debug.PrintStack()
|
||||
t.Fatalf("Notify prop %v not found. User: %v", key, user.Id)
|
||||
} else if actual != value {
|
||||
debug.PrintStack()
|
||||
t.Fatalf("Notify Prop %v was %v but expected %v. User: %v", key, actual, value, user.Id)
|
||||
}
|
||||
actual, ok := user.NotifyProps[key]
|
||||
require.True(t, ok, "Notify prop %v not found. User: %v", key, user.Id)
|
||||
require.Equalf(t, actual, value, "Notify Prop %v was %v but expected %v. User: %v", key, actual, value, user.Id)
|
||||
}
|
||||
|
||||
func checkError(t *testing.T, err *model.AppError) {
|
||||
if err == nil {
|
||||
debug.PrintStack()
|
||||
t.Fatal("Should have returned an error.")
|
||||
}
|
||||
require.NotNil(t, err, "Should have returned an error.")
|
||||
}
|
||||
|
||||
func checkNoError(t *testing.T, err *model.AppError) {
|
||||
if err != nil {
|
||||
debug.PrintStack()
|
||||
t.Fatalf("Unexpected Error: %v", err.Error())
|
||||
}
|
||||
require.Nil(t, err, "Unexpected Error: %v", err)
|
||||
}
|
||||
|
||||
func AssertAllPostsCount(t *testing.T, a *App, initialCount int64, change int64, teamName string) {
|
||||
if result, err := a.Srv.Store.Post().AnalyticsPostCount(teamName, false, false); err != nil {
|
||||
t.Fatal(err)
|
||||
} else {
|
||||
if initialCount+change != result {
|
||||
debug.PrintStack()
|
||||
t.Fatalf("Did not find the expected number of posts.")
|
||||
}
|
||||
}
|
||||
result, err := a.Srv.Store.Post().AnalyticsPostCount(teamName, false, false)
|
||||
require.Nil(t, err)
|
||||
require.Equal(t, initialCount+change, result, "Did not find the expected number of posts.")
|
||||
}
|
||||
|
||||
func AssertChannelCount(t *testing.T, a *App, channelType string, expectedCount int64) {
|
||||
if count, err := a.Srv.Store.Channel().AnalyticsTypeCount("", channelType); err == nil {
|
||||
if count != expectedCount {
|
||||
debug.PrintStack()
|
||||
t.Fatalf("Channel count of type: %v. Expected: %v, Got: %v", channelType, expectedCount, count)
|
||||
}
|
||||
} else {
|
||||
debug.PrintStack()
|
||||
t.Fatalf("Failed to get channel count.")
|
||||
}
|
||||
count, err := a.Srv.Store.Channel().AnalyticsTypeCount("", channelType)
|
||||
require.Equalf(t, expectedCount, count, "Channel count of type: %v. Expected: %v, Got: %v", channelType, expectedCount, count)
|
||||
require.Nil(t, err, "Failed to get channel count.")
|
||||
}
|
||||
|
||||
func TestImportImportLine(t *testing.T) {
|
||||
@@ -112,51 +81,43 @@ func TestImportImportLine(t *testing.T) {
|
||||
Type: "gibberish",
|
||||
}
|
||||
|
||||
if err := th.App.ImportLine(line, false); err == nil {
|
||||
t.Fatalf("Expected an error when importing a line with invalid type.")
|
||||
}
|
||||
err := th.App.ImportLine(line, false)
|
||||
require.NotNil(t, err, "Expected an error when importing a line with invalid type.")
|
||||
|
||||
// Try import line with team type but nil team.
|
||||
line.Type = "team"
|
||||
if err := th.App.ImportLine(line, false); err == nil {
|
||||
t.Fatalf("Expected an error when importing a line of type team with a nil team.")
|
||||
}
|
||||
err = th.App.ImportLine(line, false)
|
||||
require.NotNil(t, err, "Expected an error when importing a line of type team with a nil team.")
|
||||
|
||||
// Try import line with channel type but nil channel.
|
||||
line.Type = "channel"
|
||||
if err := th.App.ImportLine(line, false); err == nil {
|
||||
t.Fatalf("Expected an error when importing a line with type channel with a nil channel.")
|
||||
}
|
||||
err = th.App.ImportLine(line, false)
|
||||
require.NotNil(t, err, "Expected an error when importing a line with type channel with a nil channel.")
|
||||
|
||||
// Try import line with user type but nil user.
|
||||
line.Type = "user"
|
||||
if err := th.App.ImportLine(line, false); err == nil {
|
||||
t.Fatalf("Expected an error when importing a line with type uesr with a nil user.")
|
||||
}
|
||||
err = th.App.ImportLine(line, false)
|
||||
require.NotNil(t, err, "Expected an error when importing a line with type user with a nil user.")
|
||||
|
||||
// Try import line with post type but nil post.
|
||||
line.Type = "post"
|
||||
if err := th.App.ImportLine(line, false); err == nil {
|
||||
t.Fatalf("Expected an error when importing a line with type post with a nil post.")
|
||||
}
|
||||
err = th.App.ImportLine(line, false)
|
||||
require.NotNil(t, err, "Expected an error when importing a line with type post with a nil post.")
|
||||
|
||||
// Try import line with direct_channel type but nil direct_channel.
|
||||
line.Type = "direct_channel"
|
||||
if err := th.App.ImportLine(line, false); err == nil {
|
||||
t.Fatalf("Expected an error when importing a line with type direct_channel with a nil direct_channel.")
|
||||
}
|
||||
err = th.App.ImportLine(line, false)
|
||||
require.NotNil(t, err, "Expected an error when importing a line with type direct_channel with a nil direct_channel.")
|
||||
|
||||
// Try import line with direct_post type but nil direct_post.
|
||||
line.Type = "direct_post"
|
||||
if err := th.App.ImportLine(line, false); err == nil {
|
||||
t.Fatalf("Expected an error when importing a line with type direct_post with a nil direct_post.")
|
||||
}
|
||||
err = th.App.ImportLine(line, false)
|
||||
require.NotNil(t, err, "Expected an error when importing a line with type direct_post with a nil direct_post.")
|
||||
|
||||
// Try import line with scheme type but nil scheme.
|
||||
line.Type = "scheme"
|
||||
if err := th.App.ImportLine(line, false); err == nil {
|
||||
t.Fatalf("Expected an error when importing a line with type scheme with a nil scheme.")
|
||||
}
|
||||
err = th.App.ImportLine(line, false)
|
||||
require.NotNil(t, err, "Expected an error when importing a line with type scheme with a nil scheme.")
|
||||
}
|
||||
|
||||
func TestStopOnError(t *testing.T) {
|
||||
@@ -208,24 +169,24 @@ func TestImportBulkImport(t *testing.T) {
|
||||
{"type": "direct_post", "direct_post": {"channel_members": ["` + username + `", "` + username2 + `", "` + username3 + `"], "user": "` + username + `", "message": "Hello Group Channel", "create_at": 123456789015}}
|
||||
{"type": "emoji", "emoji": {"name": "` + emojiName + `", "image": "` + testImage + `"}}`
|
||||
|
||||
if err, line := th.App.BulkImport(strings.NewReader(data1), false, 2); err != nil || line != 0 {
|
||||
t.Fatalf("BulkImport should have succeeded: %v, %v", err.Error(), line)
|
||||
}
|
||||
err, line := th.App.BulkImport(strings.NewReader(data1), false, 2)
|
||||
require.Nil(t, err, "BulkImport should have succeeded")
|
||||
require.Equal(t, 0, line, "BulkImport line should be 0")
|
||||
|
||||
// Run bulk import using a string that contains a line with invalid json.
|
||||
data2 := `{"type": "version", "version": 1`
|
||||
if err, line := th.App.BulkImport(strings.NewReader(data2), false, 2); err == nil || line != 1 {
|
||||
t.Fatalf("Should have failed due to invalid JSON on line 1.")
|
||||
}
|
||||
err, line = th.App.BulkImport(strings.NewReader(data2), false, 2)
|
||||
require.NotNil(t, err, "Should have failed due to invalid JSON on line 1.")
|
||||
require.Equal(t, 1, line, "Should have failed due to invalid JSON on line 1.")
|
||||
|
||||
// Run bulk import using valid JSON but missing version line at the start.
|
||||
data3 := `{"type": "team", "team": {"type": "O", "display_name": "lskmw2d7a5ao7ppwqh5ljchvr4", "name": "` + teamName + `"}}
|
||||
{"type": "channel", "channel": {"type": "O", "display_name": "xr6m6udffngark2uekvr3hoeny", "team": "` + teamName + `", "name": "` + channelName + `"}}
|
||||
{"type": "user", "user": {"username": "kufjgnkxkrhhfgbrip6qxkfsaa", "email": "kufjgnkxkrhhfgbrip6qxkfsaa@example.com"}}
|
||||
{"type": "user", "user": {"username": "bwshaim6qnc2ne7oqkd5b2s2rq", "email": "bwshaim6qnc2ne7oqkd5b2s2rq@example.com", "teams": [{"name": "` + teamName + `", "channels": [{"name": "` + channelName + `"}]}]}}`
|
||||
if err, line := th.App.BulkImport(strings.NewReader(data3), false, 2); err == nil || line != 1 {
|
||||
t.Fatalf("Should have failed due to missing version line on line 1.")
|
||||
}
|
||||
err, line = th.App.BulkImport(strings.NewReader(data3), false, 2)
|
||||
require.NotNil(t, err, "Should have failed due to missing version line on line 1.")
|
||||
require.Equal(t, 1, line, "Should have failed due to missing version line on line 1.")
|
||||
|
||||
t.Run("First item after version without type", func(t *testing.T) {
|
||||
data := `{"type": "version", "version": 1}
|
||||
@@ -241,20 +202,18 @@ func TestImportProcessImportDataFileVersionLine(t *testing.T) {
|
||||
Type: "version",
|
||||
Version: ptrInt(1),
|
||||
}
|
||||
if version, err := processImportDataFileVersionLine(data); err != nil || version != 1 {
|
||||
t.Fatalf("Expected no error and version 1.")
|
||||
}
|
||||
version, err := processImportDataFileVersionLine(data)
|
||||
require.Nil(t, err, "Expected no error")
|
||||
require.Equal(t, 1, version, "Expected version 1")
|
||||
|
||||
data.Type = "NotVersion"
|
||||
if _, err := processImportDataFileVersionLine(data); err == nil {
|
||||
t.Fatalf("Expected error on invalid version line.")
|
||||
}
|
||||
_, err = processImportDataFileVersionLine(data)
|
||||
require.NotNil(t, err, "Expected error on invalid version line.")
|
||||
|
||||
data.Type = "version"
|
||||
data.Version = nil
|
||||
if _, err := processImportDataFileVersionLine(data); err == nil {
|
||||
t.Fatalf("Expected error on invalid version line.")
|
||||
}
|
||||
_, err = processImportDataFileVersionLine(data)
|
||||
require.NotNil(t, err, "Expected error on invalid version line.")
|
||||
}
|
||||
|
||||
func GetAttachments(userId string, th *TestHelper, t *testing.T) []*model.FileInfo {
|
||||
@@ -267,12 +226,11 @@ func AssertFileIdsInPost(files []*model.FileInfo, th *TestHelper, t *testing.T)
|
||||
postId := files[0].PostId
|
||||
assert.NotNil(t, postId)
|
||||
|
||||
if posts, err := th.App.Srv.Store.Post().GetPostsByIds([]string{postId}); err != nil {
|
||||
t.Fatal(err.Error())
|
||||
} else {
|
||||
assert.Equal(t, len(posts), 1)
|
||||
for _, file := range files {
|
||||
assert.Contains(t, posts[0].FileIds, file.Id)
|
||||
}
|
||||
posts, err := th.App.Srv.Store.Post().GetPostsByIds([]string{postId})
|
||||
require.Nil(t, err)
|
||||
|
||||
assert.Equal(t, len(posts), 1)
|
||||
for _, file := range files {
|
||||
assert.Contains(t, posts[0].FileIds, file.Id)
|
||||
}
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user