MM-25478: Migrate compliancestore to plain error (#15074)
* ComplianceStore migration * Fix imports * Added one string * fix go.tools.mod Co-authored-by: Rodrigo Villablanca <villa061004@gmail.com> Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
e5edf2683d
Коммит
29c8b58fc7
@@ -4,11 +4,12 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"io/ioutil"
|
||||
|
||||
"net/http"
|
||||
|
||||
"github.com/mattermost/mattermost-server/v5/model"
|
||||
"github.com/mattermost/mattermost-server/v5/store"
|
||||
)
|
||||
|
||||
func (a *App) GetComplianceReports(page, perPage int) (model.Compliances, *model.AppError) {
|
||||
@@ -16,7 +17,12 @@ func (a *App) GetComplianceReports(page, perPage int) (model.Compliances, *model
|
||||
return nil, model.NewAppError("GetComplianceReports", "ent.compliance.licence_disable.app_error", nil, "", http.StatusNotImplemented)
|
||||
}
|
||||
|
||||
return a.Srv().Store.Compliance().GetAll(page*perPage, perPage)
|
||||
compliances, err := a.Srv().Store.Compliance().GetAll(page*perPage, perPage)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetComplianceReports", "app.compliance.get.finding.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
return compliances, nil
|
||||
}
|
||||
|
||||
func (a *App) SaveComplianceReport(job *model.Compliance) (*model.Compliance, *model.AppError) {
|
||||
@@ -28,7 +34,13 @@ func (a *App) SaveComplianceReport(job *model.Compliance) (*model.Compliance, *m
|
||||
|
||||
job, err := a.Srv().Store.Compliance().Save(job)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
var appErr *model.AppError
|
||||
switch {
|
||||
case errors.As(err, &appErr):
|
||||
return nil, appErr
|
||||
default:
|
||||
return nil, model.NewAppError("SaveComplianceReport", "app.compliance.save.saving.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
|
||||
a.Srv().Go(func() {
|
||||
@@ -43,7 +55,18 @@ func (a *App) GetComplianceReport(reportId string) (*model.Compliance, *model.Ap
|
||||
return nil, model.NewAppError("downloadComplianceReport", "ent.compliance.licence_disable.app_error", nil, "", http.StatusNotImplemented)
|
||||
}
|
||||
|
||||
return a.Srv().Store.Compliance().Get(reportId)
|
||||
compliance, err := a.Srv().Store.Compliance().Get(reportId)
|
||||
if err != nil {
|
||||
var nfErr *store.ErrNotFound
|
||||
switch {
|
||||
case errors.As(err, &nfErr):
|
||||
return nil, model.NewAppError("GetComplicanceReport", "app.compliance.get.finding.app_error", nil, nfErr.Error(), http.StatusNotFound)
|
||||
default:
|
||||
return nil, model.NewAppError("GetComplianceReport", "app.compliance.get.finding.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
|
||||
return compliance, nil
|
||||
}
|
||||
|
||||
func (a *App) GetComplianceFile(job *model.Compliance) ([]byte, *model.AppError) {
|
||||
|
||||
@@ -4,7 +4,7 @@ go 1.14
|
||||
|
||||
require (
|
||||
github.com/jstemmer/go-junit-report v0.9.1 // indirect
|
||||
github.com/mattermost/mattermost-utilities/mmgotool v0.0.0-20200720080147-779d19605c57 // indirect
|
||||
github.com/mattermost/mattermost-utilities/mmgotool v0.0.0-20200721093743-053c38dcd293 // indirect
|
||||
github.com/reflog/struct2interface v0.6.1 // indirect
|
||||
github.com/vektra/mockery v1.1.2 // indirect
|
||||
)
|
||||
|
||||
@@ -54,13 +54,8 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
|
||||
github.com/mattermost/mattermost-utilities v0.0.0-20200521071950-1be063e1b2fe h1:J3mFBH2bVwqNAdg2OFVP68wJ6jYyNu9FBHH+xBSTV5k=
|
||||
github.com/mattermost/mattermost-utilities v0.0.0-20200521071950-1be063e1b2fe/go.mod h1:B4cClV5qPUzy0eAaEDkfb/bq5I+5dyTgqTlnLPQdkcg=
|
||||
github.com/mattermost/mattermost-utilities v0.0.0-20200720080147-779d19605c57 h1:skF0+Bx/jTJRSHB8y4pviychv609+shlm8RbJQjSpWQ=
|
||||
github.com/mattermost/mattermost-utilities v0.0.0-20200720080147-779d19605c57/go.mod h1:B4cClV5qPUzy0eAaEDkfb/bq5I+5dyTgqTlnLPQdkcg=
|
||||
github.com/mattermost/mattermost-utilities v1.0.0 h1:sSFG2jvud8yJAKAhmuljBgQG/Z5C++bFJJF5U3clJv8=
|
||||
github.com/mattermost/mattermost-utilities/mmgotool v0.0.0-20200720080147-779d19605c57 h1:CMaXZflqgFvajZGLJ7mV7kjLCmQe5S9Lc7sj3irmtO8=
|
||||
github.com/mattermost/mattermost-utilities/mmgotool v0.0.0-20200720080147-779d19605c57/go.mod h1:3gKozJI8n2Y/vW37GfnFWAdehGXe5yZlt+HykK6Y3DM=
|
||||
github.com/mattermost/mattermost-utilities/mmgotool v0.0.0-20200721093743-053c38dcd293 h1:N9FaqZD58xkAIJGFGY5qdKXGlY2aNMaYQ9KkVEXv8xE=
|
||||
github.com/mattermost/mattermost-utilities/mmgotool v0.0.0-20200721093743-053c38dcd293/go.mod h1:3gKozJI8n2Y/vW37GfnFWAdehGXe5yZlt+HykK6Y3DM=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
||||
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||
|
||||
28
i18n/en.json
28
i18n/en.json
@@ -3354,6 +3354,14 @@
|
||||
"id": "app.command_webhook.try_use.invalid",
|
||||
"translation": "Invalid webhook."
|
||||
},
|
||||
{
|
||||
"id": "app.compliance.get.finding.app_error",
|
||||
"translation": "We encountered an error retrieving the compliance reports."
|
||||
},
|
||||
{
|
||||
"id": "app.compliance.save.saving.app_error",
|
||||
"translation": "We encountered an error saving the compliance report."
|
||||
},
|
||||
{
|
||||
"id": "app.emoji.create.internal_error",
|
||||
"translation": "Unable to save emoji."
|
||||
@@ -5050,6 +5058,10 @@
|
||||
"id": "ent.message_export.global_relay_export.deliver.unable_to_open_zip_file_data.app_error",
|
||||
"translation": "Unable to open the export temporary file."
|
||||
},
|
||||
{
|
||||
"id": "ent.message_export.run_export.app_error",
|
||||
"translation": "Failed to select message export data."
|
||||
},
|
||||
{
|
||||
"id": "ent.migration.migratetoldap.duplicate_field",
|
||||
"translation": "Unable to migrate AD/LDAP users with specified field. Duplicate entry detected. Please remove all duplcates and try again."
|
||||
@@ -6846,18 +6858,6 @@
|
||||
"id": "store.sql_command.update.missing.app_error",
|
||||
"translation": "Command does not exist."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_compliance.get.finding.app_error",
|
||||
"translation": "We encountered an error retrieving the compliance reports."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_compliance.message_export.app_error",
|
||||
"translation": "Failed to select message export data."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_compliance.save.saving.app_error",
|
||||
"translation": "We encountered an error saving the compliance report."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_file_info.PermanentDeleteByUser.app_error",
|
||||
"translation": "Unable to delete attachments of the user."
|
||||
@@ -6994,10 +6994,6 @@
|
||||
"id": "store.sql_post.analytics_user_counts_posts_by_day.app_error",
|
||||
"translation": "Unable to get user counts with posts."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_post.compliance_export.app_error",
|
||||
"translation": "Unable to get the compliance export posts."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_post.delete.app_error",
|
||||
"translation": "Unable to delete the post."
|
||||
|
||||
@@ -2632,7 +2632,7 @@ func (s *OpenTracingLayerCommandWebhookStore) TryUse(id string, limit int) error
|
||||
return resultVar0
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerComplianceStore) ComplianceExport(compliance *model.Compliance) ([]*model.CompliancePost, *model.AppError) {
|
||||
func (s *OpenTracingLayerComplianceStore) ComplianceExport(compliance *model.Compliance) ([]*model.CompliancePost, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ComplianceStore.ComplianceExport")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -2650,7 +2650,7 @@ func (s *OpenTracingLayerComplianceStore) ComplianceExport(compliance *model.Com
|
||||
return resultVar0, resultVar1
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerComplianceStore) Get(id string) (*model.Compliance, *model.AppError) {
|
||||
func (s *OpenTracingLayerComplianceStore) Get(id string) (*model.Compliance, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ComplianceStore.Get")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -2668,7 +2668,7 @@ func (s *OpenTracingLayerComplianceStore) Get(id string) (*model.Compliance, *mo
|
||||
return resultVar0, resultVar1
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerComplianceStore) GetAll(offset int, limit int) (model.Compliances, *model.AppError) {
|
||||
func (s *OpenTracingLayerComplianceStore) GetAll(offset int, limit int) (model.Compliances, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ComplianceStore.GetAll")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -2686,7 +2686,7 @@ func (s *OpenTracingLayerComplianceStore) GetAll(offset int, limit int) (model.C
|
||||
return resultVar0, resultVar1
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerComplianceStore) MessageExport(after int64, limit int) ([]*model.MessageExport, *model.AppError) {
|
||||
func (s *OpenTracingLayerComplianceStore) MessageExport(after int64, limit int) ([]*model.MessageExport, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ComplianceStore.MessageExport")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -2704,7 +2704,7 @@ func (s *OpenTracingLayerComplianceStore) MessageExport(after int64, limit int)
|
||||
return resultVar0, resultVar1
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerComplianceStore) Save(compliance *model.Compliance) (*model.Compliance, *model.AppError) {
|
||||
func (s *OpenTracingLayerComplianceStore) Save(compliance *model.Compliance) (*model.Compliance, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ComplianceStore.Save")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -2722,7 +2722,7 @@ func (s *OpenTracingLayerComplianceStore) Save(compliance *model.Compliance) (*m
|
||||
return resultVar0, resultVar1
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerComplianceStore) Update(compliance *model.Compliance) (*model.Compliance, *model.AppError) {
|
||||
func (s *OpenTracingLayerComplianceStore) Update(compliance *model.Compliance) (*model.Compliance, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ComplianceStore.Update")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
|
||||
@@ -4,12 +4,13 @@
|
||||
package sqlstore
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/mattermost/mattermost-server/v5/model"
|
||||
"github.com/mattermost/mattermost-server/v5/store"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
type SqlComplianceStore struct {
|
||||
@@ -36,51 +37,51 @@ func newSqlComplianceStore(sqlStore SqlStore) store.ComplianceStore {
|
||||
func (s SqlComplianceStore) createIndexesIfNotExists() {
|
||||
}
|
||||
|
||||
func (s SqlComplianceStore) Save(compliance *model.Compliance) (*model.Compliance, *model.AppError) {
|
||||
func (s SqlComplianceStore) Save(compliance *model.Compliance) (*model.Compliance, error) {
|
||||
compliance.PreSave()
|
||||
if err := compliance.IsValid(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err := s.GetMaster().Insert(compliance); err != nil {
|
||||
return nil, model.NewAppError("SqlComplianceStore.Save", "store.sql_compliance.save.saving.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
return nil, errors.Wrap(err, "failed to save Compliance")
|
||||
}
|
||||
return compliance, nil
|
||||
}
|
||||
|
||||
func (s SqlComplianceStore) Update(compliance *model.Compliance) (*model.Compliance, *model.AppError) {
|
||||
func (s SqlComplianceStore) Update(compliance *model.Compliance) (*model.Compliance, error) {
|
||||
if err := compliance.IsValid(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if _, err := s.GetMaster().Update(compliance); err != nil {
|
||||
return nil, model.NewAppError("SqlComplianceStore.Update", "store.sql_compliance.save.saving.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
return nil, errors.Wrap(err, "failed to update Compliance")
|
||||
}
|
||||
return compliance, nil
|
||||
}
|
||||
|
||||
func (s SqlComplianceStore) GetAll(offset, limit int) (model.Compliances, *model.AppError) {
|
||||
func (s SqlComplianceStore) GetAll(offset, limit int) (model.Compliances, error) {
|
||||
query := "SELECT * FROM Compliances ORDER BY CreateAt DESC LIMIT :Limit OFFSET :Offset"
|
||||
|
||||
var compliances model.Compliances
|
||||
if _, err := s.GetReplica().Select(&compliances, query, map[string]interface{}{"Offset": offset, "Limit": limit}); err != nil {
|
||||
return nil, model.NewAppError("SqlComplianceStore.Get", "store.sql_compliance.get.finding.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
return nil, errors.Wrap(err, "failed to find all Compliances")
|
||||
}
|
||||
return compliances, nil
|
||||
}
|
||||
|
||||
func (s SqlComplianceStore) Get(id string) (*model.Compliance, *model.AppError) {
|
||||
func (s SqlComplianceStore) Get(id string) (*model.Compliance, error) {
|
||||
obj, err := s.GetReplica().Get(model.Compliance{}, id)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("SqlComplianceStore.Get", "store.sql_compliance.get.finding.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
return nil, errors.Wrapf(err, "failed to get Compliance with id=%s", id)
|
||||
}
|
||||
if obj == nil {
|
||||
return nil, model.NewAppError("SqlComplianceStore.Get", "store.sql_compliance.get.finding.app_error", nil, "", http.StatusNotFound)
|
||||
return nil, store.NewErrNotFound("Compliance", id)
|
||||
}
|
||||
return obj.(*model.Compliance), nil
|
||||
}
|
||||
|
||||
func (s SqlComplianceStore) ComplianceExport(job *model.Compliance) ([]*model.CompliancePost, *model.AppError) {
|
||||
func (s SqlComplianceStore) ComplianceExport(job *model.Compliance) ([]*model.CompliancePost, error) {
|
||||
props := map[string]interface{}{"StartTime": job.StartAt, "EndTime": job.EndAt}
|
||||
|
||||
keywordQuery := ""
|
||||
@@ -201,12 +202,12 @@ func (s SqlComplianceStore) ComplianceExport(job *model.Compliance) ([]*model.Co
|
||||
var cposts []*model.CompliancePost
|
||||
|
||||
if _, err := s.GetReplica().Select(&cposts, query, props); err != nil {
|
||||
return nil, model.NewAppError("SqlPostStore.ComplianceExport", "store.sql_post.compliance_export.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
return nil, errors.Wrap(err, "unable to export compliance")
|
||||
}
|
||||
return cposts, nil
|
||||
}
|
||||
|
||||
func (s SqlComplianceStore) MessageExport(after int64, limit int) ([]*model.MessageExport, *model.AppError) {
|
||||
func (s SqlComplianceStore) MessageExport(after int64, limit int) ([]*model.MessageExport, error) {
|
||||
props := map[string]interface{}{"StartTime": after, "Limit": limit}
|
||||
query :=
|
||||
`SELECT
|
||||
@@ -250,7 +251,7 @@ func (s SqlComplianceStore) MessageExport(after int64, limit int) ([]*model.Mess
|
||||
|
||||
var cposts []*model.MessageExport
|
||||
if _, err := s.GetReplica().Select(&cposts, query, props); err != nil {
|
||||
return nil, model.NewAppError("SqlComplianceStore.MessageExport", "store.sql_compliance.message_export.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
return nil, errors.Wrap(err, "unable to export messages")
|
||||
}
|
||||
return cposts, nil
|
||||
}
|
||||
|
||||
@@ -402,12 +402,12 @@ type ClusterDiscoveryStore interface {
|
||||
}
|
||||
|
||||
type ComplianceStore interface {
|
||||
Save(compliance *model.Compliance) (*model.Compliance, *model.AppError)
|
||||
Update(compliance *model.Compliance) (*model.Compliance, *model.AppError)
|
||||
Get(id string) (*model.Compliance, *model.AppError)
|
||||
GetAll(offset, limit int) (model.Compliances, *model.AppError)
|
||||
ComplianceExport(compliance *model.Compliance) ([]*model.CompliancePost, *model.AppError)
|
||||
MessageExport(after int64, limit int) ([]*model.MessageExport, *model.AppError)
|
||||
Save(compliance *model.Compliance) (*model.Compliance, error)
|
||||
Update(compliance *model.Compliance) (*model.Compliance, error)
|
||||
Get(id string) (*model.Compliance, error)
|
||||
GetAll(offset, limit int) (model.Compliances, error)
|
||||
ComplianceExport(compliance *model.Compliance) ([]*model.CompliancePost, error)
|
||||
MessageExport(after int64, limit int) ([]*model.MessageExport, error)
|
||||
}
|
||||
|
||||
type OAuthStore interface {
|
||||
|
||||
@@ -165,40 +165,40 @@ func testComplianceExport(t *testing.T, ss store.Store) {
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
|
||||
cr1 := &model.Compliance{Desc: "test" + model.NewId(), StartAt: o1.CreateAt - 1, EndAt: o2a.CreateAt + 1}
|
||||
cposts, err := ss.Compliance().ComplianceExport(cr1)
|
||||
require.Nil(t, err)
|
||||
cposts, nErr := ss.Compliance().ComplianceExport(cr1)
|
||||
require.Nil(t, nErr)
|
||||
assert.Len(t, cposts, 4)
|
||||
assert.Equal(t, cposts[0].PostId, o1.Id)
|
||||
assert.Equal(t, cposts[3].PostId, o2a.Id)
|
||||
|
||||
cr2 := &model.Compliance{Desc: "test" + model.NewId(), StartAt: o1.CreateAt - 1, EndAt: o2a.CreateAt + 1, Emails: u2.Email}
|
||||
cposts, err = ss.Compliance().ComplianceExport(cr2)
|
||||
require.Nil(t, err)
|
||||
cposts, nErr = ss.Compliance().ComplianceExport(cr2)
|
||||
require.Nil(t, nErr)
|
||||
assert.Len(t, cposts, 1)
|
||||
assert.Equal(t, cposts[0].PostId, o2a.Id)
|
||||
|
||||
cr3 := &model.Compliance{Desc: "test" + model.NewId(), StartAt: o1.CreateAt - 1, EndAt: o2a.CreateAt + 1, Emails: u2.Email + ", " + u1.Email}
|
||||
cposts, err = ss.Compliance().ComplianceExport(cr3)
|
||||
require.Nil(t, err)
|
||||
cposts, nErr = ss.Compliance().ComplianceExport(cr3)
|
||||
require.Nil(t, nErr)
|
||||
assert.Len(t, cposts, 4)
|
||||
assert.Equal(t, cposts[0].PostId, o1.Id)
|
||||
assert.Equal(t, cposts[3].PostId, o2a.Id)
|
||||
|
||||
cr4 := &model.Compliance{Desc: "test" + model.NewId(), StartAt: o1.CreateAt - 1, EndAt: o2a.CreateAt + 1, Keywords: o2a.Message}
|
||||
cposts, err = ss.Compliance().ComplianceExport(cr4)
|
||||
require.Nil(t, err)
|
||||
cposts, nErr = ss.Compliance().ComplianceExport(cr4)
|
||||
require.Nil(t, nErr)
|
||||
assert.Len(t, cposts, 1)
|
||||
assert.Equal(t, cposts[0].PostId, o2a.Id)
|
||||
|
||||
cr5 := &model.Compliance{Desc: "test" + model.NewId(), StartAt: o1.CreateAt - 1, EndAt: o2a.CreateAt + 1, Keywords: o2a.Message + " " + o1.Message}
|
||||
cposts, err = ss.Compliance().ComplianceExport(cr5)
|
||||
require.Nil(t, err)
|
||||
cposts, nErr = ss.Compliance().ComplianceExport(cr5)
|
||||
require.Nil(t, nErr)
|
||||
assert.Len(t, cposts, 2)
|
||||
assert.Equal(t, cposts[0].PostId, o1.Id)
|
||||
|
||||
cr6 := &model.Compliance{Desc: "test" + model.NewId(), StartAt: o1.CreateAt - 1, EndAt: o2a.CreateAt + 1, Emails: u2.Email + ", " + u1.Email, Keywords: o2a.Message + " " + o1.Message}
|
||||
cposts, err = ss.Compliance().ComplianceExport(cr6)
|
||||
require.Nil(t, err)
|
||||
cposts, nErr = ss.Compliance().ComplianceExport(cr6)
|
||||
require.Nil(t, nErr)
|
||||
assert.Len(t, cposts, 2)
|
||||
assert.Equal(t, cposts[0].PostId, o1.Id)
|
||||
assert.Equal(t, cposts[1].PostId, o2a.Id)
|
||||
@@ -284,8 +284,8 @@ func testComplianceExportDirectMessages(t *testing.T, ss store.Store) {
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
|
||||
cr1 := &model.Compliance{Desc: "test" + model.NewId(), StartAt: o1.CreateAt - 1, EndAt: o3.CreateAt + 1, Emails: u1.Email}
|
||||
cposts, err := ss.Compliance().ComplianceExport(cr1)
|
||||
require.Nil(t, err)
|
||||
cposts, nErr := ss.Compliance().ComplianceExport(cr1)
|
||||
require.Nil(t, nErr)
|
||||
assert.Len(t, cposts, 4)
|
||||
assert.Equal(t, cposts[0].PostId, o1.Id)
|
||||
assert.Equal(t, cposts[len(cposts)-1].PostId, o3.Id)
|
||||
|
||||
@@ -15,7 +15,7 @@ type ComplianceStore struct {
|
||||
}
|
||||
|
||||
// ComplianceExport provides a mock function with given fields: compliance
|
||||
func (_m *ComplianceStore) ComplianceExport(compliance *model.Compliance) ([]*model.CompliancePost, *model.AppError) {
|
||||
func (_m *ComplianceStore) ComplianceExport(compliance *model.Compliance) ([]*model.CompliancePost, error) {
|
||||
ret := _m.Called(compliance)
|
||||
|
||||
var r0 []*model.CompliancePost
|
||||
@@ -27,20 +27,18 @@ func (_m *ComplianceStore) ComplianceExport(compliance *model.Compliance) ([]*mo
|
||||
}
|
||||
}
|
||||
|
||||
var r1 *model.AppError
|
||||
if rf, ok := ret.Get(1).(func(*model.Compliance) *model.AppError); ok {
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(*model.Compliance) error); ok {
|
||||
r1 = rf(compliance)
|
||||
} else {
|
||||
if ret.Get(1) != nil {
|
||||
r1 = ret.Get(1).(*model.AppError)
|
||||
}
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// Get provides a mock function with given fields: id
|
||||
func (_m *ComplianceStore) Get(id string) (*model.Compliance, *model.AppError) {
|
||||
func (_m *ComplianceStore) Get(id string) (*model.Compliance, error) {
|
||||
ret := _m.Called(id)
|
||||
|
||||
var r0 *model.Compliance
|
||||
@@ -52,20 +50,18 @@ func (_m *ComplianceStore) Get(id string) (*model.Compliance, *model.AppError) {
|
||||
}
|
||||
}
|
||||
|
||||
var r1 *model.AppError
|
||||
if rf, ok := ret.Get(1).(func(string) *model.AppError); ok {
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(string) error); ok {
|
||||
r1 = rf(id)
|
||||
} else {
|
||||
if ret.Get(1) != nil {
|
||||
r1 = ret.Get(1).(*model.AppError)
|
||||
}
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// GetAll provides a mock function with given fields: offset, limit
|
||||
func (_m *ComplianceStore) GetAll(offset int, limit int) (model.Compliances, *model.AppError) {
|
||||
func (_m *ComplianceStore) GetAll(offset int, limit int) (model.Compliances, error) {
|
||||
ret := _m.Called(offset, limit)
|
||||
|
||||
var r0 model.Compliances
|
||||
@@ -77,20 +73,18 @@ func (_m *ComplianceStore) GetAll(offset int, limit int) (model.Compliances, *mo
|
||||
}
|
||||
}
|
||||
|
||||
var r1 *model.AppError
|
||||
if rf, ok := ret.Get(1).(func(int, int) *model.AppError); ok {
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(int, int) error); ok {
|
||||
r1 = rf(offset, limit)
|
||||
} else {
|
||||
if ret.Get(1) != nil {
|
||||
r1 = ret.Get(1).(*model.AppError)
|
||||
}
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// MessageExport provides a mock function with given fields: after, limit
|
||||
func (_m *ComplianceStore) MessageExport(after int64, limit int) ([]*model.MessageExport, *model.AppError) {
|
||||
func (_m *ComplianceStore) MessageExport(after int64, limit int) ([]*model.MessageExport, error) {
|
||||
ret := _m.Called(after, limit)
|
||||
|
||||
var r0 []*model.MessageExport
|
||||
@@ -102,20 +96,18 @@ func (_m *ComplianceStore) MessageExport(after int64, limit int) ([]*model.Messa
|
||||
}
|
||||
}
|
||||
|
||||
var r1 *model.AppError
|
||||
if rf, ok := ret.Get(1).(func(int64, int) *model.AppError); ok {
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(int64, int) error); ok {
|
||||
r1 = rf(after, limit)
|
||||
} else {
|
||||
if ret.Get(1) != nil {
|
||||
r1 = ret.Get(1).(*model.AppError)
|
||||
}
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// Save provides a mock function with given fields: compliance
|
||||
func (_m *ComplianceStore) Save(compliance *model.Compliance) (*model.Compliance, *model.AppError) {
|
||||
func (_m *ComplianceStore) Save(compliance *model.Compliance) (*model.Compliance, error) {
|
||||
ret := _m.Called(compliance)
|
||||
|
||||
var r0 *model.Compliance
|
||||
@@ -127,20 +119,18 @@ func (_m *ComplianceStore) Save(compliance *model.Compliance) (*model.Compliance
|
||||
}
|
||||
}
|
||||
|
||||
var r1 *model.AppError
|
||||
if rf, ok := ret.Get(1).(func(*model.Compliance) *model.AppError); ok {
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(*model.Compliance) error); ok {
|
||||
r1 = rf(compliance)
|
||||
} else {
|
||||
if ret.Get(1) != nil {
|
||||
r1 = ret.Get(1).(*model.AppError)
|
||||
}
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// Update provides a mock function with given fields: compliance
|
||||
func (_m *ComplianceStore) Update(compliance *model.Compliance) (*model.Compliance, *model.AppError) {
|
||||
func (_m *ComplianceStore) Update(compliance *model.Compliance) (*model.Compliance, error) {
|
||||
ret := _m.Called(compliance)
|
||||
|
||||
var r0 *model.Compliance
|
||||
@@ -152,13 +142,11 @@ func (_m *ComplianceStore) Update(compliance *model.Compliance) (*model.Complian
|
||||
}
|
||||
}
|
||||
|
||||
var r1 *model.AppError
|
||||
if rf, ok := ret.Get(1).(func(*model.Compliance) *model.AppError); ok {
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(*model.Compliance) error); ok {
|
||||
r1 = rf(compliance)
|
||||
} else {
|
||||
if ret.Get(1) != nil {
|
||||
r1 = ret.Get(1).(*model.AppError)
|
||||
}
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
|
||||
@@ -2416,7 +2416,7 @@ func (s *TimerLayerCommandWebhookStore) TryUse(id string, limit int) error {
|
||||
return resultVar0
|
||||
}
|
||||
|
||||
func (s *TimerLayerComplianceStore) ComplianceExport(compliance *model.Compliance) ([]*model.CompliancePost, *model.AppError) {
|
||||
func (s *TimerLayerComplianceStore) ComplianceExport(compliance *model.Compliance) ([]*model.CompliancePost, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
resultVar0, resultVar1 := s.ComplianceStore.ComplianceExport(compliance)
|
||||
@@ -2432,7 +2432,7 @@ func (s *TimerLayerComplianceStore) ComplianceExport(compliance *model.Complianc
|
||||
return resultVar0, resultVar1
|
||||
}
|
||||
|
||||
func (s *TimerLayerComplianceStore) Get(id string) (*model.Compliance, *model.AppError) {
|
||||
func (s *TimerLayerComplianceStore) Get(id string) (*model.Compliance, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
resultVar0, resultVar1 := s.ComplianceStore.Get(id)
|
||||
@@ -2448,7 +2448,7 @@ func (s *TimerLayerComplianceStore) Get(id string) (*model.Compliance, *model.Ap
|
||||
return resultVar0, resultVar1
|
||||
}
|
||||
|
||||
func (s *TimerLayerComplianceStore) GetAll(offset int, limit int) (model.Compliances, *model.AppError) {
|
||||
func (s *TimerLayerComplianceStore) GetAll(offset int, limit int) (model.Compliances, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
resultVar0, resultVar1 := s.ComplianceStore.GetAll(offset, limit)
|
||||
@@ -2464,7 +2464,7 @@ func (s *TimerLayerComplianceStore) GetAll(offset int, limit int) (model.Complia
|
||||
return resultVar0, resultVar1
|
||||
}
|
||||
|
||||
func (s *TimerLayerComplianceStore) MessageExport(after int64, limit int) ([]*model.MessageExport, *model.AppError) {
|
||||
func (s *TimerLayerComplianceStore) MessageExport(after int64, limit int) ([]*model.MessageExport, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
resultVar0, resultVar1 := s.ComplianceStore.MessageExport(after, limit)
|
||||
@@ -2480,7 +2480,7 @@ func (s *TimerLayerComplianceStore) MessageExport(after int64, limit int) ([]*mo
|
||||
return resultVar0, resultVar1
|
||||
}
|
||||
|
||||
func (s *TimerLayerComplianceStore) Save(compliance *model.Compliance) (*model.Compliance, *model.AppError) {
|
||||
func (s *TimerLayerComplianceStore) Save(compliance *model.Compliance) (*model.Compliance, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
resultVar0, resultVar1 := s.ComplianceStore.Save(compliance)
|
||||
@@ -2496,7 +2496,7 @@ func (s *TimerLayerComplianceStore) Save(compliance *model.Compliance) (*model.C
|
||||
return resultVar0, resultVar1
|
||||
}
|
||||
|
||||
func (s *TimerLayerComplianceStore) Update(compliance *model.Compliance) (*model.Compliance, *model.AppError) {
|
||||
func (s *TimerLayerComplianceStore) Update(compliance *model.Compliance) (*model.Compliance, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
resultVar0, resultVar1 := s.ComplianceStore.Update(compliance)
|
||||
|
||||
Ссылка в новой задаче
Block a user