OSF: Used model.NewPointer everywhere (#27838)

```release-note
NONE
```
Этот коммит содержится в:
Agniva De Sarker
2024-08-06 09:15:00 +05:30
коммит произвёл GitHub
родитель f290745496
Коммит c3ed07e679
148 изменённых файлов: 2341 добавлений и 2338 удалений

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

@@ -145,7 +145,7 @@ func getMockStore(t *testing.T) *mocks.Store {
fakeUser := []*model.User{{
Id: "123",
AuthData: model.NewString("authData"),
AuthData: model.NewPointer("authData"),
AuthService: "authService",
}}
mockUserStore := mocks.UserStore{}
@@ -164,7 +164,7 @@ func getMockStore(t *testing.T) *mocks.Store {
fakeUser[0],
{
Id: "456",
AuthData: model.NewString("authData"),
AuthData: model.NewPointer("authData"),
AuthService: "authService",
},
}

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

@@ -25,7 +25,7 @@ func TestUserStoreCache(t *testing.T) {
fakeUserIds := []string{"123"}
fakeUser := []*model.User{{
Id: "123",
AuthData: model.NewString("authData"),
AuthData: model.NewPointer("authData"),
AuthService: "authService",
}}
@@ -231,7 +231,7 @@ func TestUserStoreGetCache(t *testing.T) {
fakeUserId := "123"
fakeUser := &model.User{
Id: "123",
AuthData: model.NewString("authData"),
AuthData: model.NewPointer("authData"),
AuthService: "authService",
}
t.Run("first call not cached, second cached and returning same data", func(t *testing.T) {
@@ -301,12 +301,12 @@ func TestUserStoreGetCache(t *testing.T) {
func TestUserStoreGetManyCache(t *testing.T) {
fakeUser := &model.User{
Id: "123",
AuthData: model.NewString("authData"),
AuthData: model.NewPointer("authData"),
AuthService: "authService",
}
otherFakeUser := &model.User{
Id: "456",
AuthData: model.NewString("authData"),
AuthData: model.NewPointer("authData"),
AuthService: "authService",
}
t.Run("first call not cached, second cached and returning same data", func(t *testing.T) {

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

@@ -33,7 +33,7 @@ func TestUpdateConfigRace(t *testing.T) {
cfg := &model.Config{}
cfg.SetDefaults()
cfg.ClusterSettings.GossipPort = model.NewInt(9999)
cfg.ClusterSettings.GossipPort = model.NewPointer(9999)
searchEngine := searchengine.NewBroker(cfg)
layer := searchlayer.NewSearchLayer(&testlib.TestStore{Store: store}, searchEngine, cfg)
var wg sync.WaitGroup

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

@@ -153,7 +153,7 @@ func (s SqlChannelMemberHistoryStore) getFromChannelMembersTable(startTime int64
// we have to fill in the join/leave times, because that data doesn't exist in the channel members table
for _, channelMemberHistory := range histories {
channelMemberHistory.JoinTime = startTime
channelMemberHistory.LeaveTime = model.NewInt64(endTime)
channelMemberHistory.LeaveTime = model.NewPointer(endTime)
}
return histories, nil
}

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

@@ -593,7 +593,7 @@ func (s SqlChannelStore) CreateDirectChannel(rctx request.CTX, user *model.User,
channel.Header = ""
channel.Type = model.ChannelTypeDirect
channel.Shared = model.NewBool(user.IsRemote() || otherUser.IsRemote())
channel.Shared = model.NewPointer(user.IsRemote() || otherUser.IsRemote())
channel.CreatorId = user.Id
cm1 := &model.ChannelMember{

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

@@ -1157,7 +1157,7 @@ type groupWithSchemeAdmin struct {
func (g groupWithSchemeAdmin) ToModel() *model.GroupWithSchemeAdmin {
if g.SyncableSchemeAdmin == nil {
g.SyncableSchemeAdmin = model.NewBool(false)
g.SyncableSchemeAdmin = model.NewPointer(false)
}
res := &model.GroupWithSchemeAdmin{
Group: *g.group.ToModel(),

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

@@ -856,7 +856,7 @@ func TestCheckTeamsChannelsIntegrity(t *testing.T) {
ChildId: &channel.Id,
}, data.Records[0])
require.Equal(t, model.OrphanedRecord{
ParentId: model.NewString("test"),
ParentId: model.NewPointer("test"),
ChildId: &direct.Id,
}, data.Records[1])
dbmap.Exec(`DELETE FROM Channels WHERE Id=?`, channel.Id)

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

@@ -1156,7 +1156,7 @@ func (s *SqlPostStore) prepareThreadedResponse(posts []*postWithExtra, extended,
processPost := func(p *postWithExtra) error {
p.Post.ReplyCount = p.ThreadReplyCount
if p.IsFollowing != nil {
p.Post.IsFollowing = model.NewBool(*p.IsFollowing)
p.Post.IsFollowing = model.NewPointer(*p.IsFollowing)
}
for _, userID := range p.ThreadParticipants {
participant, ok := usersMap[userID]

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

@@ -462,7 +462,7 @@ func (s *SqlRetentionPolicyStore) GetChannels(policyId string, offset, limit int
}
for _, channel := range channels {
channel.PolicyID = model.NewString(policyId)
channel.PolicyID = model.NewPointer(policyId)
}
return channels, nil

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

@@ -537,8 +537,8 @@ func TestIsBinaryParamEnabled(t *testing.T) {
{
store: SqlStore{
settings: &model.SqlSettings{
DriverName: model.NewString(model.DatabaseDriverPostgres),
DataSource: model.NewString("postgres://mmuser:mostest@localhost/loadtest?sslmode=disable\u0026binary_parameters=yes"),
DriverName: model.NewPointer(model.DatabaseDriverPostgres),
DataSource: model.NewPointer("postgres://mmuser:mostest@localhost/loadtest?sslmode=disable\u0026binary_parameters=yes"),
},
},
expected: true,
@@ -546,8 +546,8 @@ func TestIsBinaryParamEnabled(t *testing.T) {
{
store: SqlStore{
settings: &model.SqlSettings{
DriverName: model.NewString(model.DatabaseDriverMysql),
DataSource: model.NewString("postgres://mmuser:mostest@localhost/loadtest?sslmode=disable\u0026binary_parameters=yes"),
DriverName: model.NewPointer(model.DatabaseDriverMysql),
DataSource: model.NewPointer("postgres://mmuser:mostest@localhost/loadtest?sslmode=disable\u0026binary_parameters=yes"),
},
},
expected: false,
@@ -555,8 +555,8 @@ func TestIsBinaryParamEnabled(t *testing.T) {
{
store: SqlStore{
settings: &model.SqlSettings{
DriverName: model.NewString(model.DatabaseDriverPostgres),
DataSource: model.NewString("postgres://mmuser:mostest@localhost/loadtest?sslmode=disable&binary_parameters=yes"),
DriverName: model.NewPointer(model.DatabaseDriverPostgres),
DataSource: model.NewPointer("postgres://mmuser:mostest@localhost/loadtest?sslmode=disable&binary_parameters=yes"),
},
},
expected: true,
@@ -564,8 +564,8 @@ func TestIsBinaryParamEnabled(t *testing.T) {
{
store: SqlStore{
settings: &model.SqlSettings{
DriverName: model.NewString(model.DatabaseDriverPostgres),
DataSource: model.NewString("postgres://mmuser:mostest@localhost/loadtest?sslmode=disable"),
DriverName: model.NewPointer(model.DatabaseDriverPostgres),
DataSource: model.NewPointer("postgres://mmuser:mostest@localhost/loadtest?sslmode=disable"),
},
},
expected: false,
@@ -760,9 +760,9 @@ func TestReplicaLagQuery(t *testing.T) {
}
settings.ReplicaLagSettings = []*model.ReplicaLagSettings{{
DataSource: model.NewString(*settings.DataSource),
QueryAbsoluteLag: model.NewString(query),
QueryTimeLag: model.NewString(query),
DataSource: model.NewPointer(*settings.DataSource),
QueryAbsoluteLag: model.NewPointer(query),
QueryTimeLag: model.NewPointer(query),
}}
mockMetrics := &mocks.MetricsInterface{}

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

@@ -546,16 +546,16 @@ func (s SqlTeamStore) SearchAllPaged(opts *model.TeamSearch) ([]*model.Team, int
// SearchOpen returns from the database a list of public teams that match the Name or DisplayName
// passed as the term search parameter.
func (s SqlTeamStore) SearchOpen(opts *model.TeamSearch) ([]*model.Team, error) {
opts.TeamType = model.NewString("O")
opts.AllowOpenInvite = model.NewBool(true)
opts.TeamType = model.NewPointer("O")
opts.AllowOpenInvite = model.NewPointer(true)
return s.SearchAll(opts)
}
// SearchPrivate returns from the database a list of private teams that match the Name or DisplayName
// passed as the term search parameter.
func (s SqlTeamStore) SearchPrivate(opts *model.TeamSearch) ([]*model.Team, error) {
opts.TeamType = model.NewString("O")
opts.AllowOpenInvite = model.NewBool(false)
opts.TeamType = model.NewPointer("O")
opts.AllowOpenInvite = model.NewPointer(false)
return s.SearchAll(opts)
}

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

@@ -377,7 +377,7 @@ func testPermanentDeleteBatchForRetentionPolicies(t *testing.T, rctx request.CTX
channelPolicy, err := ss.RetentionPolicy().Save(&model.RetentionPolicyWithTeamAndChannelIDs{
RetentionPolicy: model.RetentionPolicy{
DisplayName: "DisplayName",
PostDurationDays: model.NewInt64(30),
PostDurationDays: model.NewPointer(int64(30)),
},
ChannelIDs: []string{channel.Id},
})

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

@@ -3858,10 +3858,10 @@ func testChannelStoreGetAllChannels(t *testing.T, rctx request.CTX, ss store.Sto
require.NoError(t, nErr)
group := &model.Group{
Name: model.NewString(model.NewId()),
Name: model.NewPointer(model.NewId()),
DisplayName: model.NewId(),
Source: model.GroupSourceLdap,
RemoteId: model.NewString(model.NewId()),
RemoteId: model.NewPointer(model.NewId()),
}
_, err = ss.Group().Create(group)
require.NoError(t, err)
@@ -3949,7 +3949,7 @@ func testChannelStoreGetAllChannels(t *testing.T, rctx request.CTX, ss store.Sto
policy, nErr := ss.RetentionPolicy().Save(&model.RetentionPolicyWithTeamAndChannelIDs{
RetentionPolicy: model.RetentionPolicy{
DisplayName: "Policy 1",
PostDurationDays: model.NewInt64(30),
PostDurationDays: model.NewPointer(int64(30)),
},
ChannelIDs: []string{c1.Id},
})
@@ -4768,9 +4768,9 @@ func testCountUrgentPostsAfter(t *testing.T, rctx request.CTX, ss store.Store) {
CreateAt: 1000,
Metadata: &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString(model.PostPriorityUrgent),
RequestedAck: model.NewBool(false),
PersistentNotifications: model.NewBool(false),
Priority: model.NewPointer(model.PostPriorityUrgent),
RequestedAck: model.NewPointer(false),
PersistentNotifications: model.NewPointer(false),
},
},
})
@@ -4782,9 +4782,9 @@ func testCountUrgentPostsAfter(t *testing.T, rctx request.CTX, ss store.Store) {
CreateAt: 1001,
Metadata: &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString("important"),
RequestedAck: model.NewBool(false),
PersistentNotifications: model.NewBool(false),
Priority: model.NewPointer("important"),
RequestedAck: model.NewPointer(false),
PersistentNotifications: model.NewPointer(false),
},
},
})
@@ -4803,9 +4803,9 @@ func testCountUrgentPostsAfter(t *testing.T, rctx request.CTX, ss store.Store) {
CreateAt: 1003,
Metadata: &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString(model.PostPriorityUrgent),
RequestedAck: model.NewBool(false),
PersistentNotifications: model.NewBool(false),
Priority: model.NewPointer(model.PostPriorityUrgent),
RequestedAck: model.NewPointer(false),
PersistentNotifications: model.NewPointer(false),
},
},
})
@@ -5215,10 +5215,10 @@ func testGetMemberCountsByGroup(t *testing.T, rctx request.CTX, ss store.Store)
var memberCounts []*model.ChannelMemberCountByGroup
teamId := model.NewId()
g1 := &model.Group{
Name: model.NewString(model.NewId()),
Name: model.NewPointer(model.NewId()),
DisplayName: model.NewId(),
Source: model.GroupSourceLdap,
RemoteId: model.NewString(model.NewId()),
RemoteId: model.NewPointer(model.NewId()),
}
_, err := ss.Group().Create(g1)
require.NoError(t, err)
@@ -5287,10 +5287,10 @@ func testGetMemberCountsByGroup(t *testing.T, rctx request.CTX, ss store.Store)
})
g2 := &model.Group{
Name: model.NewString(model.NewId()),
Name: model.NewPointer(model.NewId()),
DisplayName: model.NewId(),
Source: model.GroupSourceLdap,
RemoteId: model.NewString(model.NewId()),
RemoteId: model.NewPointer(model.NewId()),
}
_, err = ss.Group().Create(g2)
require.NoError(t, err)
@@ -5326,10 +5326,10 @@ func testGetMemberCountsByGroup(t *testing.T, rctx request.CTX, ss store.Store)
}
g3 := &model.Group{
Name: model.NewString(model.NewId()),
Name: model.NewPointer(model.NewId()),
DisplayName: model.NewId(),
Source: model.GroupSourceLdap,
RemoteId: model.NewString(model.NewId()),
RemoteId: model.NewPointer(model.NewId()),
}
_, err = ss.Group().Create(g3)
@@ -6379,7 +6379,7 @@ func testChannelStoreSearchAllChannels(t *testing.T, rctx request.CTX, ss store.
DisplayName: "A5 ChannelC",
Name: NewTestId(),
Type: model.ChannelTypePrivate,
GroupConstrained: model.NewBool(true),
GroupConstrained: model.NewPointer(true),
}
_, nErr = ss.Channel().Save(rctx, &o5, -1)
require.NoError(t, nErr)
@@ -6403,10 +6403,10 @@ func testChannelStoreSearchAllChannels(t *testing.T, rctx request.CTX, ss store.
require.NoError(t, nErr)
group := &model.Group{
Name: model.NewString(model.NewId()),
Name: model.NewPointer(model.NewId()),
DisplayName: model.NewId(),
Source: model.GroupSourceLdap,
RemoteId: model.NewString(model.NewId()),
RemoteId: model.NewPointer(model.NewId()),
}
_, err = ss.Group().Create(group)
require.NoError(t, err)
@@ -6486,7 +6486,7 @@ func testChannelStoreSearchAllChannels(t *testing.T, rctx request.CTX, ss store.
_, nErr = ss.RetentionPolicy().Save(&model.RetentionPolicyWithTeamAndChannelIDs{
RetentionPolicy: model.RetentionPolicy{
DisplayName: "Policy 1",
PostDurationDays: model.NewInt64(30),
PostDurationDays: model.NewPointer(int64(30)),
},
ChannelIDs: []string{o14.Id},
})
@@ -6518,24 +6518,24 @@ func testChannelStoreSearchAllChannels(t *testing.T, rctx request.CTX, ss store.
{"exclude defaults search 'off'", "off-", store.ChannelSearchOpts{IncludeDeleted: false, ExcludeChannelNames: []string{"off-topic"}}, model.ChannelList{&o7, &o8}, 0},
{"exclude defaults search 'town'", "town", store.ChannelSearchOpts{IncludeDeleted: false, ExcludeChannelNames: []string{"town-square"}}, model.ChannelList{}, 0},
{"exclude by group association", "off-", store.ChannelSearchOpts{IncludeDeleted: false, NotAssociatedToGroup: group.Id}, model.ChannelList{&o6, &o8}, 0},
{"paginate includes count", "off-", store.ChannelSearchOpts{IncludeDeleted: false, PerPage: model.NewInt(100)}, model.ChannelList{&o6, &o7, &o8}, 3},
{"paginate, page 2 correct entries and count", "off-", store.ChannelSearchOpts{IncludeDeleted: false, PerPage: model.NewInt(2), Page: model.NewInt(1)}, model.ChannelList{&o8}, 3},
{"paginate includes count", "off-", store.ChannelSearchOpts{IncludeDeleted: false, PerPage: model.NewPointer(100)}, model.ChannelList{&o6, &o7, &o8}, 3},
{"paginate, page 2 correct entries and count", "off-", store.ChannelSearchOpts{IncludeDeleted: false, PerPage: model.NewPointer(2), Page: model.NewPointer(1)}, model.ChannelList{&o8}, 3},
{"Filter private", "", store.ChannelSearchOpts{IncludeDeleted: false, Private: true}, model.ChannelList{&o4, &o5, &o8}, 3},
{"Filter public", "", store.ChannelSearchOpts{IncludeDeleted: false, Public: true, Page: model.NewInt(0), PerPage: model.NewInt(5)}, model.ChannelList{&o1, &o2, &o3, &o6, &o7}, 10},
{"Filter public and private", "", store.ChannelSearchOpts{IncludeDeleted: false, Public: true, Private: true, Page: model.NewInt(0), PerPage: model.NewInt(5)}, model.ChannelList{&o1, &o2, &o3, &o4, &o5}, 13},
{"Filter public and private and include deleted", "", store.ChannelSearchOpts{IncludeDeleted: true, Public: true, Private: true, Page: model.NewInt(0), PerPage: model.NewInt(5)}, model.ChannelList{&o1, &o2, &o3, &o4, &o5}, 14},
{"Filter group constrained", "", store.ChannelSearchOpts{IncludeDeleted: false, GroupConstrained: true, Page: model.NewInt(0), PerPage: model.NewInt(5)}, model.ChannelList{&o5}, 1},
{"Filter exclude group constrained and include deleted", "", store.ChannelSearchOpts{IncludeDeleted: true, ExcludeGroupConstrained: true, Page: model.NewInt(0), PerPage: model.NewInt(5)}, model.ChannelList{&o1, &o2, &o3, &o4, &o6}, 13},
{"Filter private and exclude group constrained", "", store.ChannelSearchOpts{IncludeDeleted: false, ExcludeGroupConstrained: true, Private: true, Page: model.NewInt(0), PerPage: model.NewInt(5)}, model.ChannelList{&o4, &o8}, 2},
{"Filter public", "", store.ChannelSearchOpts{IncludeDeleted: false, Public: true, Page: model.NewPointer(0), PerPage: model.NewPointer(5)}, model.ChannelList{&o1, &o2, &o3, &o6, &o7}, 10},
{"Filter public and private", "", store.ChannelSearchOpts{IncludeDeleted: false, Public: true, Private: true, Page: model.NewPointer(0), PerPage: model.NewPointer(5)}, model.ChannelList{&o1, &o2, &o3, &o4, &o5}, 13},
{"Filter public and private and include deleted", "", store.ChannelSearchOpts{IncludeDeleted: true, Public: true, Private: true, Page: model.NewPointer(0), PerPage: model.NewPointer(5)}, model.ChannelList{&o1, &o2, &o3, &o4, &o5}, 14},
{"Filter group constrained", "", store.ChannelSearchOpts{IncludeDeleted: false, GroupConstrained: true, Page: model.NewPointer(0), PerPage: model.NewPointer(5)}, model.ChannelList{&o5}, 1},
{"Filter exclude group constrained and include deleted", "", store.ChannelSearchOpts{IncludeDeleted: true, ExcludeGroupConstrained: true, Page: model.NewPointer(0), PerPage: model.NewPointer(5)}, model.ChannelList{&o1, &o2, &o3, &o4, &o6}, 13},
{"Filter private and exclude group constrained", "", store.ChannelSearchOpts{IncludeDeleted: false, ExcludeGroupConstrained: true, Private: true, Page: model.NewPointer(0), PerPage: model.NewPointer(5)}, model.ChannelList{&o4, &o8}, 2},
{"Exclude policy constrained", "", store.ChannelSearchOpts{ExcludePolicyConstrained: true}, model.ChannelList{&o1, &o2, &o3, &o4, &o5, &o6, &o7, &o8, &o9, &o10, &o11, &o12}, 0},
{"Filter team 2", "", store.ChannelSearchOpts{IncludeDeleted: false, TeamIds: []string{t2.Id}, Page: model.NewInt(0), PerPage: model.NewInt(5)}, model.ChannelList{&o2, &o14}, 2},
{"Filter team 2, private", "", store.ChannelSearchOpts{IncludeDeleted: false, TeamIds: []string{t2.Id}, Private: true, Page: model.NewInt(0), PerPage: model.NewInt(5)}, model.ChannelList{}, 0},
{"Filter team 1 and team 2, private", "", store.ChannelSearchOpts{IncludeDeleted: false, TeamIds: []string{t1.Id, t2.Id}, Private: true, Page: model.NewInt(0), PerPage: model.NewInt(5)}, model.ChannelList{&o4, &o5, &o8}, 3},
{"Filter team 1 and team 2, public and private", "", store.ChannelSearchOpts{IncludeDeleted: false, TeamIds: []string{t1.Id, t2.Id}, Public: true, Private: true, Page: model.NewInt(0), PerPage: model.NewInt(5)}, model.ChannelList{&o1, &o2, &o3, &o4, &o5}, 13},
{"Filter team 1 and team 2, public and private and group constrained", "", store.ChannelSearchOpts{IncludeDeleted: false, TeamIds: []string{t1.Id, t2.Id}, Public: true, Private: true, GroupConstrained: true, Page: model.NewInt(0), PerPage: model.NewInt(5)}, model.ChannelList{&o5}, 1},
{"Filter team 1 and team 2, public and private and exclude group constrained", "", store.ChannelSearchOpts{IncludeDeleted: false, TeamIds: []string{t1.Id, t2.Id}, Public: true, Private: true, ExcludeGroupConstrained: true, Page: model.NewInt(0), PerPage: model.NewInt(5)}, model.ChannelList{&o1, &o2, &o3, &o4, &o6}, 12},
{"Filter deleted returns only deleted channels", "", store.ChannelSearchOpts{Deleted: true, Page: model.NewInt(0), PerPage: model.NewInt(5)}, model.ChannelList{&o13}, 1},
{"Search ChannelA by id", o1.Id, store.ChannelSearchOpts{IncludeDeleted: false, Page: model.NewInt(0), PerPage: model.NewInt(5), IncludeSearchById: true}, model.ChannelList{&o1}, 1},
{"Filter team 2", "", store.ChannelSearchOpts{IncludeDeleted: false, TeamIds: []string{t2.Id}, Page: model.NewPointer(0), PerPage: model.NewPointer(5)}, model.ChannelList{&o2, &o14}, 2},
{"Filter team 2, private", "", store.ChannelSearchOpts{IncludeDeleted: false, TeamIds: []string{t2.Id}, Private: true, Page: model.NewPointer(0), PerPage: model.NewPointer(5)}, model.ChannelList{}, 0},
{"Filter team 1 and team 2, private", "", store.ChannelSearchOpts{IncludeDeleted: false, TeamIds: []string{t1.Id, t2.Id}, Private: true, Page: model.NewPointer(0), PerPage: model.NewPointer(5)}, model.ChannelList{&o4, &o5, &o8}, 3},
{"Filter team 1 and team 2, public and private", "", store.ChannelSearchOpts{IncludeDeleted: false, TeamIds: []string{t1.Id, t2.Id}, Public: true, Private: true, Page: model.NewPointer(0), PerPage: model.NewPointer(5)}, model.ChannelList{&o1, &o2, &o3, &o4, &o5}, 13},
{"Filter team 1 and team 2, public and private and group constrained", "", store.ChannelSearchOpts{IncludeDeleted: false, TeamIds: []string{t1.Id, t2.Id}, Public: true, Private: true, GroupConstrained: true, Page: model.NewPointer(0), PerPage: model.NewPointer(5)}, model.ChannelList{&o5}, 1},
{"Filter team 1 and team 2, public and private and exclude group constrained", "", store.ChannelSearchOpts{IncludeDeleted: false, TeamIds: []string{t1.Id, t2.Id}, Public: true, Private: true, ExcludeGroupConstrained: true, Page: model.NewPointer(0), PerPage: model.NewPointer(5)}, model.ChannelList{&o1, &o2, &o3, &o4, &o6}, 12},
{"Filter deleted returns only deleted channels", "", store.ChannelSearchOpts{Deleted: true, Page: model.NewPointer(0), PerPage: model.NewPointer(5)}, model.ChannelList{&o13}, 1},
{"Search ChannelA by id", o1.Id, store.ChannelSearchOpts{IncludeDeleted: false, Page: model.NewPointer(0), PerPage: model.NewPointer(5), IncludeSearchById: true}, model.ChannelList{&o1}, 1},
}
for _, testCase := range testCases {
@@ -7929,7 +7929,7 @@ func testGroupSyncedChannelCount(t *testing.T, rctx request.CTX, ss store.Store)
DisplayName: model.NewId(),
Name: model.NewId(),
Type: model.ChannelTypePrivate,
GroupConstrained: model.NewBool(true),
GroupConstrained: model.NewPointer(true),
}, 999)
require.NoError(t, nErr)
require.True(t, channel1.IsGroupConstrained())
@@ -7948,7 +7948,7 @@ func testGroupSyncedChannelCount(t *testing.T, rctx request.CTX, ss store.Store)
require.NoError(t, err)
require.GreaterOrEqual(t, count, int64(1))
channel2.GroupConstrained = model.NewBool(true)
channel2.GroupConstrained = model.NewPointer(true)
channel2, err = ss.Channel().Update(rctx, channel2)
require.NoError(t, err)
require.True(t, channel2.IsGroupConstrained())

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@@ -28,9 +28,9 @@ func testPostAcknowledgementsStoreSave(t *testing.T, rctx request.CTX, ss store.
p1.Message = NewTestId()
p1.Metadata = &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString("important"),
RequestedAck: model.NewBool(true),
PersistentNotifications: model.NewBool(false),
Priority: model.NewPointer("important"),
RequestedAck: model.NewPointer(true),
PersistentNotifications: model.NewPointer(false),
},
}
post, err := ss.Post().Save(rctx, &p1)
@@ -73,9 +73,9 @@ func testPostAcknowledgementsStoreGetForPost(t *testing.T, rctx request.CTX, ss
p1.Message = NewTestId()
p1.Metadata = &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString("important"),
RequestedAck: model.NewBool(true),
PersistentNotifications: model.NewBool(false),
Priority: model.NewPointer("important"),
RequestedAck: model.NewPointer(true),
PersistentNotifications: model.NewPointer(false),
},
}
_, err := ss.Post().Save(rctx, &p1)
@@ -124,9 +124,9 @@ func testPostAcknowledgementsStoreGetForPosts(t *testing.T, rctx request.CTX, ss
p1.Message = NewTestId()
p1.Metadata = &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString("important"),
RequestedAck: model.NewBool(true),
PersistentNotifications: model.NewBool(false),
Priority: model.NewPointer("important"),
RequestedAck: model.NewPointer(true),
PersistentNotifications: model.NewPointer(false),
},
}
p2 := model.Post{}
@@ -135,9 +135,9 @@ func testPostAcknowledgementsStoreGetForPosts(t *testing.T, rctx request.CTX, ss
p2.Message = NewTestId()
p2.Metadata = &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString(""),
RequestedAck: model.NewBool(true),
PersistentNotifications: model.NewBool(false),
Priority: model.NewPointer(""),
RequestedAck: model.NewPointer(true),
PersistentNotifications: model.NewPointer(false),
},
}
_, errIdx, err := ss.Post().SaveMultiple([]*model.Post{&p1, &p2})

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

@@ -28,9 +28,9 @@ func testPostPersistentNotificationStoreGet(t *testing.T, rctx request.CTX, ss s
p1.CreateAt = 10
p1.Metadata = &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString("important"),
RequestedAck: model.NewBool(false),
PersistentNotifications: model.NewBool(true),
Priority: model.NewPointer("important"),
RequestedAck: model.NewPointer(false),
PersistentNotifications: model.NewPointer(true),
},
}
@@ -41,9 +41,9 @@ func testPostPersistentNotificationStoreGet(t *testing.T, rctx request.CTX, ss s
p2.CreateAt = 20
p2.Metadata = &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString(model.PostPriorityUrgent),
RequestedAck: model.NewBool(true),
PersistentNotifications: model.NewBool(true),
Priority: model.NewPointer(model.PostPriorityUrgent),
RequestedAck: model.NewPointer(true),
PersistentNotifications: model.NewPointer(true),
},
}
@@ -62,9 +62,9 @@ func testPostPersistentNotificationStoreGet(t *testing.T, rctx request.CTX, ss s
p4.CreateAt = 40
p4.Metadata = &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString(model.PostPriorityUrgent),
RequestedAck: model.NewBool(false),
PersistentNotifications: model.NewBool(false),
Priority: model.NewPointer(model.PostPriorityUrgent),
RequestedAck: model.NewPointer(false),
PersistentNotifications: model.NewPointer(false),
},
}
@@ -75,9 +75,9 @@ func testPostPersistentNotificationStoreGet(t *testing.T, rctx request.CTX, ss s
p5.CreateAt = 50
p5.Metadata = &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString(model.PostPriorityUrgent),
RequestedAck: model.NewBool(false),
PersistentNotifications: model.NewBool(true),
Priority: model.NewPointer(model.PostPriorityUrgent),
RequestedAck: model.NewPointer(false),
PersistentNotifications: model.NewPointer(true),
},
}
@@ -150,9 +150,9 @@ func testPostPersistentNotificationStoreUpdateLastSentAt(t *testing.T, rctx requ
p1.CreateAt = 10
p1.Metadata = &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString("important"),
RequestedAck: model.NewBool(false),
PersistentNotifications: model.NewBool(true),
Priority: model.NewPointer("important"),
RequestedAck: model.NewPointer(false),
PersistentNotifications: model.NewPointer(true),
},
}
@@ -203,9 +203,9 @@ func testPostPersistentNotificationStoreDelete(t *testing.T, rctx request.CTX, s
p1.CreateAt = 10
p1.Metadata = &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString("important"),
RequestedAck: model.NewBool(false),
PersistentNotifications: model.NewBool(true),
Priority: model.NewPointer("important"),
RequestedAck: model.NewPointer(false),
PersistentNotifications: model.NewPointer(true),
},
}
@@ -216,9 +216,9 @@ func testPostPersistentNotificationStoreDelete(t *testing.T, rctx request.CTX, s
p2.CreateAt = 20
p2.Metadata = &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString(model.PostPriorityUrgent),
RequestedAck: model.NewBool(true),
PersistentNotifications: model.NewBool(true),
Priority: model.NewPointer(model.PostPriorityUrgent),
RequestedAck: model.NewPointer(true),
PersistentNotifications: model.NewPointer(true),
},
}
@@ -229,9 +229,9 @@ func testPostPersistentNotificationStoreDelete(t *testing.T, rctx request.CTX, s
p3.CreateAt = 30
p3.Metadata = &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString(model.PostPriorityUrgent),
RequestedAck: model.NewBool(false),
PersistentNotifications: model.NewBool(true),
Priority: model.NewPointer(model.PostPriorityUrgent),
RequestedAck: model.NewPointer(false),
PersistentNotifications: model.NewPointer(true),
},
}
@@ -263,9 +263,9 @@ func testPostPersistentNotificationStoreDelete(t *testing.T, rctx request.CTX, s
p1.CreateAt = 10
p1.Metadata = &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString("important"),
RequestedAck: model.NewBool(false),
PersistentNotifications: model.NewBool(true),
Priority: model.NewPointer("important"),
RequestedAck: model.NewPointer(false),
PersistentNotifications: model.NewPointer(true),
},
}
@@ -276,9 +276,9 @@ func testPostPersistentNotificationStoreDelete(t *testing.T, rctx request.CTX, s
p2.CreateAt = 20
p2.Metadata = &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString(model.PostPriorityUrgent),
RequestedAck: model.NewBool(true),
PersistentNotifications: model.NewBool(true),
Priority: model.NewPointer(model.PostPriorityUrgent),
RequestedAck: model.NewPointer(true),
PersistentNotifications: model.NewPointer(true),
},
}
@@ -289,9 +289,9 @@ func testPostPersistentNotificationStoreDelete(t *testing.T, rctx request.CTX, s
p3.CreateAt = 30
p3.Metadata = &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString(model.PostPriorityUrgent),
RequestedAck: model.NewBool(false),
PersistentNotifications: model.NewBool(true),
Priority: model.NewPointer(model.PostPriorityUrgent),
RequestedAck: model.NewPointer(false),
PersistentNotifications: model.NewPointer(true),
},
}
@@ -302,9 +302,9 @@ func testPostPersistentNotificationStoreDelete(t *testing.T, rctx request.CTX, s
p4.CreateAt = 40
p4.Metadata = &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString("important"),
RequestedAck: model.NewBool(false),
PersistentNotifications: model.NewBool(true),
Priority: model.NewPointer("important"),
RequestedAck: model.NewPointer(false),
PersistentNotifications: model.NewPointer(true),
},
}
@@ -315,9 +315,9 @@ func testPostPersistentNotificationStoreDelete(t *testing.T, rctx request.CTX, s
p5.CreateAt = 50
p5.Metadata = &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString("important"),
RequestedAck: model.NewBool(false),
PersistentNotifications: model.NewBool(true),
Priority: model.NewPointer("important"),
RequestedAck: model.NewPointer(false),
PersistentNotifications: model.NewPointer(true),
},
}
@@ -367,9 +367,9 @@ func testPostPersistentNotificationStoreDelete(t *testing.T, rctx request.CTX, s
p1.CreateAt = 10
p1.Metadata = &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString("important"),
RequestedAck: model.NewBool(false),
PersistentNotifications: model.NewBool(true),
Priority: model.NewPointer("important"),
RequestedAck: model.NewPointer(false),
PersistentNotifications: model.NewPointer(true),
},
}
@@ -380,9 +380,9 @@ func testPostPersistentNotificationStoreDelete(t *testing.T, rctx request.CTX, s
p2.CreateAt = 20
p2.Metadata = &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString(model.PostPriorityUrgent),
RequestedAck: model.NewBool(true),
PersistentNotifications: model.NewBool(true),
Priority: model.NewPointer(model.PostPriorityUrgent),
RequestedAck: model.NewPointer(true),
PersistentNotifications: model.NewPointer(true),
},
}
@@ -393,9 +393,9 @@ func testPostPersistentNotificationStoreDelete(t *testing.T, rctx request.CTX, s
p3.CreateAt = 30
p3.Metadata = &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString(model.PostPriorityUrgent),
RequestedAck: model.NewBool(false),
PersistentNotifications: model.NewBool(true),
Priority: model.NewPointer(model.PostPriorityUrgent),
RequestedAck: model.NewPointer(false),
PersistentNotifications: model.NewPointer(true),
},
}
@@ -406,9 +406,9 @@ func testPostPersistentNotificationStoreDelete(t *testing.T, rctx request.CTX, s
p4.CreateAt = 40
p4.Metadata = &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString("important"),
RequestedAck: model.NewBool(false),
PersistentNotifications: model.NewBool(true),
Priority: model.NewPointer("important"),
RequestedAck: model.NewPointer(false),
PersistentNotifications: model.NewPointer(true),
},
}
@@ -419,9 +419,9 @@ func testPostPersistentNotificationStoreDelete(t *testing.T, rctx request.CTX, s
p5.CreateAt = 50
p5.Metadata = &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString("important"),
RequestedAck: model.NewBool(false),
PersistentNotifications: model.NewBool(true),
Priority: model.NewPointer("important"),
RequestedAck: model.NewPointer(false),
PersistentNotifications: model.NewPointer(true),
},
}

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

@@ -28,9 +28,9 @@ func testPostPriorityStoreGetForPost(t *testing.T, rctx request.CTX, ss store.St
p1.Message = NewTestId()
p1.Metadata = &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString("important"),
RequestedAck: model.NewBool(true),
PersistentNotifications: model.NewBool(false),
Priority: model.NewPointer("important"),
RequestedAck: model.NewPointer(true),
PersistentNotifications: model.NewPointer(false),
},
}
@@ -40,9 +40,9 @@ func testPostPriorityStoreGetForPost(t *testing.T, rctx request.CTX, ss store.St
p2.Message = NewTestId()
p2.Metadata = &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString(model.PostPriorityUrgent),
RequestedAck: model.NewBool(false),
PersistentNotifications: model.NewBool(true),
Priority: model.NewPointer(model.PostPriorityUrgent),
RequestedAck: model.NewPointer(false),
PersistentNotifications: model.NewPointer(true),
},
}

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

@@ -249,9 +249,9 @@ func testPostStoreSave(t *testing.T, rctx request.CTX, ss store.Store) {
o1.Metadata = &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString("important"),
RequestedAck: model.NewBool(true),
PersistentNotifications: model.NewBool(false),
Priority: model.NewPointer("important"),
RequestedAck: model.NewPointer(true),
PersistentNotifications: model.NewPointer(false),
},
}
@@ -4061,7 +4061,7 @@ func testPostStorePermanentDeleteBatch(t *testing.T, rctx request.CTX, ss store.
channelPolicy, err2 := ss.RetentionPolicy().Save(&model.RetentionPolicyWithTeamAndChannelIDs{
RetentionPolicy: model.RetentionPolicy{
DisplayName: "DisplayName",
PostDurationDays: model.NewInt64(30),
PostDurationDays: model.NewPointer(int64(30)),
},
ChannelIDs: []string{channel.Id},
})
@@ -4090,7 +4090,7 @@ func testPostStorePermanentDeleteBatch(t *testing.T, rctx request.CTX, ss store.
teamPolicy, err2 := ss.RetentionPolicy().Save(&model.RetentionPolicyWithTeamAndChannelIDs{
RetentionPolicy: model.RetentionPolicy{
DisplayName: "DisplayName",
PostDurationDays: model.NewInt64(20),
PostDurationDays: model.NewPointer(int64(20)),
},
TeamIDs: []string{team.Id},
})
@@ -4150,7 +4150,7 @@ func testPostStorePermanentDeleteBatch(t *testing.T, rctx request.CTX, ss store.
channelPolicy, err2 := ss.RetentionPolicy().Save(&model.RetentionPolicyWithTeamAndChannelIDs{
RetentionPolicy: model.RetentionPolicy{
DisplayName: "DisplayName",
PostDurationDays: model.NewInt64(30),
PostDurationDays: model.NewPointer(int64(30)),
},
ChannelIDs: []string{c1.Id},
})
@@ -4159,7 +4159,7 @@ func testPostStorePermanentDeleteBatch(t *testing.T, rctx request.CTX, ss store.
teamPolicy, err2 := ss.RetentionPolicy().Save(&model.RetentionPolicyWithTeamAndChannelIDs{
RetentionPolicy: model.RetentionPolicy{
DisplayName: "DisplayName",
PostDurationDays: model.NewInt64(30),
PostDurationDays: model.NewPointer(int64(30)),
},
TeamIDs: []string{team.Id},
})
@@ -4662,7 +4662,7 @@ func testHasAutoResponsePostByUserSince(t *testing.T, rctx request.CTX, ss store
func testGetPostsSinceUpdateForSync(t *testing.T, rctx request.CTX, ss store.Store, s SqlStore) {
// create some posts.
channelID := model.NewId()
remoteID := model.NewString(model.NewId())
remoteID := model.NewPointer(model.NewId())
first := model.GetMillis()
data := []*model.Post{
@@ -4681,7 +4681,7 @@ func testGetPostsSinceUpdateForSync(t *testing.T, rctx request.CTX, ss store.Sto
for i, p := range data {
p.UpdateAt = first + (int64(i) * 300000)
if p.RemoteId == nil {
p.RemoteId = model.NewString(model.NewId())
p.RemoteId = model.NewPointer(model.NewId())
}
_, err := ss.Post().Save(rctx, p)
require.NoError(t, err, "couldn't save post")
@@ -4765,7 +4765,7 @@ func testGetPostsSinceUpdateForSync(t *testing.T, rctx request.CTX, ss store.Sto
func testGetPostsSinceCreateForSync(t *testing.T, rctx request.CTX, ss store.Store, s SqlStore) {
// create some posts.
channelID := model.NewId()
remoteID := model.NewString(model.NewId())
remoteID := model.NewPointer(model.NewId())
first := model.GetMillis()
data := []*model.Post{
@@ -4784,7 +4784,7 @@ func testGetPostsSinceCreateForSync(t *testing.T, rctx request.CTX, ss store.Sto
for i, p := range data {
p.CreateAt = first + (int64(i) * 300000)
if p.RemoteId == nil {
p.RemoteId = model.NewString(model.NewId())
p.RemoteId = model.NewPointer(model.NewId())
}
_, err := ss.Post().Save(rctx, p)
require.NoError(t, err, "couldn't save post")

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

@@ -982,7 +982,7 @@ func testReactionGetSingle(t *testing.T, rctx request.CTX, ss store.Store) {
UserId: testUserID,
PostId: post.Id,
EmojiName: testEmojiName,
RemoteId: model.NewString(testRemoteID),
RemoteId: model.NewPointer(testRemoteID),
}
_, nErr := ss.Reaction().Save(reaction)
@@ -1007,7 +1007,7 @@ func testReactionGetSingle(t *testing.T, rctx request.CTX, ss store.Store) {
UserId: testUserID,
PostId: post.Id,
EmojiName: testEmojiName,
RemoteId: model.NewString(testRemoteID),
RemoteId: model.NewPointer(testRemoteID),
}
_, nErr := ss.Reaction().Save(reaction)

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

@@ -174,7 +174,7 @@ func createRetentionPolicyWithTeamAndChannelIds(displayName string, teamIDs, cha
return &model.RetentionPolicyWithTeamAndChannelIDs{
RetentionPolicy: model.RetentionPolicy{
DisplayName: displayName,
PostDurationDays: model.NewInt64(30),
PostDurationDays: model.NewPointer(int64(30)),
},
TeamIDs: teamIDs,
ChannelIDs: channelIDs,
@@ -254,7 +254,7 @@ func testRetentionPolicyStorePatch(t *testing.T, rctx request.CTX, ss store.Stor
patch := &model.RetentionPolicyWithTeamAndChannelIDs{
RetentionPolicy: model.RetentionPolicy{
ID: policy.ID,
PostDurationDays: model.NewInt64(10000),
PostDurationDays: model.NewPointer(int64(10000)),
},
}
_, err := ss.RetentionPolicy().Patch(patch)
@@ -264,7 +264,7 @@ func testRetentionPolicyStorePatch(t *testing.T, rctx request.CTX, ss store.Stor
checkRetentionPolicyLikeThisExists(t, ss, expected)
// Store a negative value (= infinity)
patch.PostDurationDays = model.NewInt64(-1)
patch.PostDurationDays = model.NewPointer(int64(-1))
_, err = ss.RetentionPolicy().Patch(patch)
require.NoError(t, err)
expected = copyRetentionPolicyWithTeamAndChannelIds(policy)

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

@@ -172,8 +172,8 @@ func databaseSettings(driver, dataSource string) *model.SqlSettings {
ConnMaxLifetimeMilliseconds: new(int),
ConnMaxIdleTimeMilliseconds: new(int),
MaxOpenConns: new(int),
Trace: model.NewBool(false),
AtRestEncryptKey: model.NewString(model.NewRandomString(32)),
Trace: model.NewPointer(false),
AtRestEncryptKey: model.NewPointer(model.NewRandomString(32)),
QueryTimeout: new(int),
MigrationsStatementTimeoutSeconds: new(int),
}
@@ -261,7 +261,7 @@ func MakeSqlSettings(driver string, withReplica bool) *model.SqlSettings {
}
log("Created temporary " + driver + " database " + dbName)
settings.ReplicaMonitorIntervalSeconds = model.NewInt(5)
settings.ReplicaMonitorIntervalSeconds = model.NewPointer(5)
return settings
}

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

@@ -869,7 +869,7 @@ func createSharedTestChannel(ss store.Store, rctx request.CTX, name string, shar
Header: name + " header",
Purpose: name + "purpose",
CreatorId: model.NewId(),
Shared: model.NewBool(shared),
Shared: model.NewPointer(shared),
}
channel, err := ss.Channel().Save(rctx, channel, 10000)
if err != nil {

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

@@ -276,7 +276,7 @@ func testTeamStoreSearchAll(t *testing.T, rctx request.CTX, ss store.Store) {
g.Email = MakeEmail()
g.Type = model.TeamOpen
g.AllowOpenInvite = false
g.GroupConstrained = model.NewBool(true)
g.GroupConstrained = model.NewPointer(true)
_, err = ss.Team().Save(&g)
require.NoError(t, err)
@@ -294,7 +294,7 @@ func testTeamStoreSearchAll(t *testing.T, rctx request.CTX, ss store.Store) {
_, err = ss.RetentionPolicy().Save(&model.RetentionPolicyWithTeamAndChannelIDs{
RetentionPolicy: model.RetentionPolicy{
DisplayName: "Policy 1",
PostDurationDays: model.NewInt64(20),
PostDurationDays: model.NewPointer(int64(20)),
},
TeamIDs: []string{q.Id},
})
@@ -368,55 +368,55 @@ func testTeamStoreSearchAll(t *testing.T, rctx request.CTX, ss store.Store) {
},
{
"Search for all 3 teams filter by allow open invite",
&model.TeamSearch{Term: "searchterm", AllowOpenInvite: model.NewBool(true)},
&model.TeamSearch{Term: "searchterm", AllowOpenInvite: model.NewPointer(true)},
1,
[]string{o.Id},
},
{
"Search for all 3 teams filter by allow open invite = false",
&model.TeamSearch{Term: "searchterm", AllowOpenInvite: model.NewBool(false)},
&model.TeamSearch{Term: "searchterm", AllowOpenInvite: model.NewPointer(false)},
1,
[]string{p.Id},
},
{
"Search for all 3 teams filter by group constrained",
&model.TeamSearch{Term: "searchterm", GroupConstrained: model.NewBool(true)},
&model.TeamSearch{Term: "searchterm", GroupConstrained: model.NewPointer(true)},
1,
[]string{g.Id},
},
{
"Search for all 3 teams filter by group constrained = false",
&model.TeamSearch{Term: "searchterm", GroupConstrained: model.NewBool(false)},
&model.TeamSearch{Term: "searchterm", GroupConstrained: model.NewPointer(false)},
2,
[]string{o.Id, p.Id},
},
{
"Search for all 3 teams filter by allow open invite and include group constrained",
&model.TeamSearch{Term: "searchterm", AllowOpenInvite: model.NewBool(true), GroupConstrained: model.NewBool(true)},
&model.TeamSearch{Term: "searchterm", AllowOpenInvite: model.NewPointer(true), GroupConstrained: model.NewPointer(true)},
2,
[]string{o.Id, g.Id},
},
{
"Search for all 3 teams filter by group constrained and not open invite",
&model.TeamSearch{Term: "searchterm", GroupConstrained: model.NewBool(true), AllowOpenInvite: model.NewBool(false)},
&model.TeamSearch{Term: "searchterm", GroupConstrained: model.NewPointer(true), AllowOpenInvite: model.NewPointer(false)},
2,
[]string{g.Id, p.Id},
},
{
"Search for all 3 teams filter by group constrained false and open invite",
&model.TeamSearch{Term: "searchterm", GroupConstrained: model.NewBool(false), AllowOpenInvite: model.NewBool(true)},
&model.TeamSearch{Term: "searchterm", GroupConstrained: model.NewPointer(false), AllowOpenInvite: model.NewPointer(true)},
2,
[]string{o.Id, p.Id},
},
{
"Search for all 3 teams filter by group constrained false and open invite false",
&model.TeamSearch{Term: "searchterm", GroupConstrained: model.NewBool(false), AllowOpenInvite: model.NewBool(false)},
&model.TeamSearch{Term: "searchterm", GroupConstrained: model.NewPointer(false), AllowOpenInvite: model.NewPointer(false)},
2,
[]string{p.Id, o.Id},
},
{
"Search for teams which are not part of a data retention policy",
&model.TeamSearch{Term: "", ExcludePolicyConstrained: model.NewBool(true)},
&model.TeamSearch{Term: "", ExcludePolicyConstrained: model.NewPointer(true)},
3,
[]string{o.Id, p.Id, g.Id},
},
@@ -700,7 +700,7 @@ func testTeamStoreGetAllPage(t *testing.T, rctx request.CTX, ss store.Store) {
policy, err := ss.RetentionPolicy().Save(&model.RetentionPolicyWithTeamAndChannelIDs{
RetentionPolicy: model.RetentionPolicy{
DisplayName: "Policy 1",
PostDurationDays: model.NewInt64(30),
PostDurationDays: model.NewPointer(int64(30)),
},
TeamIDs: []string{o.Id},
})
@@ -720,7 +720,7 @@ func testTeamStoreGetAllPage(t *testing.T, rctx request.CTX, ss store.Store) {
require.True(t, found)
// With ExcludePolicyConstrained
teams, err = ss.Team().GetAllPage(0, 100, &model.TeamSearch{ExcludePolicyConstrained: model.NewBool(true)})
teams, err = ss.Team().GetAllPage(0, 100, &model.TeamSearch{ExcludePolicyConstrained: model.NewPointer(true)})
require.NoError(t, err)
found = false
for _, team := range teams {
@@ -732,7 +732,7 @@ func testTeamStoreGetAllPage(t *testing.T, rctx request.CTX, ss store.Store) {
require.False(t, found)
// With policy ID
teams, err = ss.Team().GetAllPage(0, 100, &model.TeamSearch{IncludePolicyID: model.NewBool(true)})
teams, err = ss.Team().GetAllPage(0, 100, &model.TeamSearch{IncludePolicyID: model.NewPointer(true)})
require.NoError(t, err)
found = false
for _, team := range teams {
@@ -826,7 +826,7 @@ func testGetAllTeamPageListing(t *testing.T, rctx request.CTX, ss store.Store) {
_, err = ss.Team().Save(&o4)
require.NoError(t, err)
opts := &model.TeamSearch{AllowOpenInvite: model.NewBool(true)}
opts := &model.TeamSearch{AllowOpenInvite: model.NewPointer(true)}
teams, err := ss.Team().GetAllPage(0, 10, opts)
require.NoError(t, err)
@@ -946,7 +946,7 @@ func testGetAllPrivateTeamPageListing(t *testing.T, rctx request.CTX, ss store.S
_, err = ss.Team().Save(&o4)
require.NoError(t, err)
opts := &model.TeamSearch{AllowOpenInvite: model.NewBool(false)}
opts := &model.TeamSearch{AllowOpenInvite: model.NewPointer(false)}
teams, listErr := ss.Team().GetAllPage(0, 10, opts)
require.NoError(t, listErr)
@@ -1021,7 +1021,7 @@ func testGetAllPublicTeamPageListing(t *testing.T, rctx request.CTX, ss store.St
_, err = ss.Team().Save(&o4)
require.NoError(t, err)
opts := &model.TeamSearch{AllowOpenInvite: model.NewBool(true)}
opts := &model.TeamSearch{AllowOpenInvite: model.NewPointer(true)}
teams, err := ss.Team().GetAllPage(0, 10, opts)
assert.NoError(t, err)
@@ -1096,7 +1096,7 @@ func testPublicTeamCount(t *testing.T, rctx request.CTX, ss store.Store) {
_, err = ss.Team().Save(&o3)
require.NoError(t, err)
teamCount, err := ss.Team().AnalyticsTeamCount(&model.TeamSearch{AllowOpenInvite: model.NewBool(true)})
teamCount, err := ss.Team().AnalyticsTeamCount(&model.TeamSearch{AllowOpenInvite: model.NewPointer(true)})
require.NoError(t, err)
require.Equal(t, int64(2), teamCount, "should only be 1 team")
}
@@ -1131,7 +1131,7 @@ func testPrivateTeamCount(t *testing.T, rctx request.CTX, ss store.Store) {
_, err = ss.Team().Save(&o3)
require.NoError(t, err)
teamCount, err := ss.Team().AnalyticsTeamCount(&model.TeamSearch{AllowOpenInvite: model.NewBool(false)})
teamCount, err := ss.Team().AnalyticsTeamCount(&model.TeamSearch{AllowOpenInvite: model.NewPointer(false)})
require.NoError(t, err)
require.Equal(t, int64(2), teamCount, "should only be 1 team")
}
@@ -1161,7 +1161,7 @@ func testTeamCount(t *testing.T, rctx request.CTX, ss store.Store) {
require.NoError(t, err)
// get the count of teams including deleted
countIncludingDeleted, err := ss.Team().AnalyticsTeamCount(&model.TeamSearch{IncludeDeleted: model.NewBool(true)})
countIncludingDeleted, err := ss.Team().AnalyticsTeamCount(&model.TeamSearch{IncludeDeleted: model.NewPointer(true)})
require.NoError(t, err)
// count including deleted should be one greater than not including deleted
@@ -3589,7 +3589,7 @@ func testGroupSyncedTeamCount(t *testing.T, rctx request.CTX, ss store.Store) {
Name: NewTestId(),
Email: MakeEmail(),
Type: model.TeamInvite,
GroupConstrained: model.NewBool(true),
GroupConstrained: model.NewPointer(true),
})
require.NoError(t, err)
require.True(t, team1.IsGroupConstrained())
@@ -3609,7 +3609,7 @@ func testGroupSyncedTeamCount(t *testing.T, rctx request.CTX, ss store.Store) {
require.NoError(t, err)
require.GreaterOrEqual(t, count, int64(1))
team2.GroupConstrained = model.NewBool(true)
team2.GroupConstrained = model.NewPointer(true)
team2, err = ss.Team().Update(team2)
require.NoError(t, err)
require.True(t, team2.IsGroupConstrained())

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

@@ -64,9 +64,9 @@ func testThreadStorePopulation(t *testing.T, rctx request.CTX, ss store.Store) {
if urgent {
o.Metadata = &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString(model.PostPriorityUrgent),
RequestedAck: model.NewBool(false),
PersistentNotifications: model.NewBool(false),
Priority: model.NewPointer(model.PostPriorityUrgent),
RequestedAck: model.NewPointer(false),
PersistentNotifications: model.NewPointer(false),
},
}
}
@@ -520,7 +520,7 @@ func testThreadStorePermanentDeleteBatchForRetentionPolicies(t *testing.T, rctx
channelPolicy, err := ss.RetentionPolicy().Save(&model.RetentionPolicyWithTeamAndChannelIDs{
RetentionPolicy: model.RetentionPolicy{
DisplayName: "DisplayName",
PostDurationDays: model.NewInt64(30),
PostDurationDays: model.NewPointer(int64(30)),
},
ChannelIDs: []string{channel.Id},
})
@@ -542,7 +542,7 @@ func testThreadStorePermanentDeleteBatchForRetentionPolicies(t *testing.T, rctx
teamPolicy, err := ss.RetentionPolicy().Save(&model.RetentionPolicyWithTeamAndChannelIDs{
RetentionPolicy: model.RetentionPolicy{
DisplayName: "DisplayName",
PostDurationDays: model.NewInt64(20),
PostDurationDays: model.NewPointer(int64(20)),
},
TeamIDs: []string{team.Id},
})
@@ -607,7 +607,7 @@ func testThreadStorePermanentDeleteBatchThreadMembershipsForRetentionPolicies(t
channelPolicy, err := ss.RetentionPolicy().Save(&model.RetentionPolicyWithTeamAndChannelIDs{
RetentionPolicy: model.RetentionPolicy{
DisplayName: "DisplayName",
PostDurationDays: model.NewInt64(30),
PostDurationDays: model.NewPointer(int64(30)),
},
ChannelIDs: []string{channel.Id},
})
@@ -626,7 +626,7 @@ func testThreadStorePermanentDeleteBatchThreadMembershipsForRetentionPolicies(t
teamPolicy, err := ss.RetentionPolicy().Save(&model.RetentionPolicyWithTeamAndChannelIDs{
RetentionPolicy: model.RetentionPolicy{
DisplayName: "DisplayName",
PostDurationDays: model.NewInt64(20),
PostDurationDays: model.NewPointer(int64(20)),
},
TeamIDs: []string{team.Id},
})
@@ -739,9 +739,9 @@ func testGetTeamsUnreadForUser(t *testing.T, rctx request.CTX, ss store.Store) {
Message: model.NewRandomString(10),
Metadata: &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString(model.PostPriorityUrgent),
RequestedAck: model.NewBool(false),
PersistentNotifications: model.NewBool(false),
Priority: model.NewPointer(model.PostPriorityUrgent),
RequestedAck: model.NewPointer(false),
PersistentNotifications: model.NewPointer(false),
},
},
})
@@ -881,9 +881,9 @@ func testVarious(t *testing.T, rctx request.CTX, ss store.Store) {
Message: model.NewRandomString(10),
Metadata: &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString(model.PostPriorityUrgent),
RequestedAck: model.NewBool(false),
PersistentNotifications: model.NewBool(false),
Priority: model.NewPointer(model.PostPriorityUrgent),
RequestedAck: model.NewPointer(false),
PersistentNotifications: model.NewPointer(false),
},
},
})

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

@@ -1605,10 +1605,10 @@ func testUserStoreGetProfilesNotInChannel(t *testing.T, rctx request.CTX, ss sto
// create a group
group, err := ss.Group().Create(&model.Group{
Name: model.NewString("n_" + model.NewId()),
Name: model.NewPointer("n_" + model.NewId()),
DisplayName: "dn_" + model.NewId(),
Source: model.GroupSourceLdap,
RemoteId: model.NewString("ri_" + model.NewId()),
RemoteId: model.NewPointer("ri_" + model.NewId()),
})
require.NoError(t, err)
@@ -2357,7 +2357,7 @@ func testUserStoreResetAuthDataToEmailForUsers(t *testing.T, rctx request.CTX, s
resetAuthDataToID := func() {
_, err = ss.User().UpdateAuthData(
user.Id, model.UserAuthServiceSaml, model.NewString("some-id"), "", false)
user.Id, model.UserAuthServiceSaml, model.NewPointer("some-id"), "", false)
require.NoError(t, err)
}
resetAuthDataToID()
@@ -3694,28 +3694,28 @@ func testUserStoreSearchInGroup(t *testing.T, rctx request.CTX, ss store.Store)
defer func() { require.NoError(t, ss.User().PermanentDelete(rctx, u3.Id)) }()
// The users returned from the database will have AuthData as an empty string.
nilAuthData := model.NewString("")
nilAuthData := model.NewPointer("")
u1.AuthData = nilAuthData
u2.AuthData = nilAuthData
u3.AuthData = nilAuthData
g1 := &model.Group{
Name: model.NewString(NewTestId()),
Name: model.NewPointer(NewTestId()),
DisplayName: NewTestId(),
Description: NewTestId(),
Source: model.GroupSourceLdap,
RemoteId: model.NewString(NewTestId()),
RemoteId: model.NewPointer(NewTestId()),
}
_, err = ss.Group().Create(g1)
require.NoError(t, err)
g2 := &model.Group{
Name: model.NewString(NewTestId()),
Name: model.NewPointer(NewTestId()),
DisplayName: NewTestId(),
Description: NewTestId(),
Source: model.GroupSourceLdap,
RemoteId: model.NewString(NewTestId()),
RemoteId: model.NewPointer(NewTestId()),
}
_, err = ss.Group().Create(g2)
require.NoError(t, err)
@@ -3837,28 +3837,28 @@ func testUserStoreSearchNotInGroup(t *testing.T, rctx request.CTX, ss store.Stor
defer func() { require.NoError(t, ss.User().PermanentDelete(rctx, u3.Id)) }()
// The users returned from the database will have AuthData as an empty string.
nilAuthData := model.NewString("")
nilAuthData := model.NewPointer("")
u1.AuthData = nilAuthData
u2.AuthData = nilAuthData
u3.AuthData = nilAuthData
g1 := &model.Group{
Name: model.NewString(NewTestId()),
Name: model.NewPointer(NewTestId()),
DisplayName: NewTestId(),
Description: NewTestId(),
Source: model.GroupSourceCustom,
RemoteId: model.NewString(NewTestId()),
RemoteId: model.NewPointer(NewTestId()),
}
_, err = ss.Group().Create(g1)
require.NoError(t, err)
g2 := &model.Group{
Name: model.NewString(NewTestId()),
Name: model.NewPointer(NewTestId()),
DisplayName: NewTestId(),
Description: NewTestId(),
Source: model.GroupSourceCustom,
RemoteId: model.NewString(NewTestId()),
RemoteId: model.NewPointer(NewTestId()),
}
_, err = ss.Group().Create(g2)
require.NoError(t, err)
@@ -4764,10 +4764,10 @@ func testUserStoreGetProfilesNotInTeam(t *testing.T, rctx request.CTX, ss store.
// create a group
group, err := ss.Group().Create(&model.Group{
Name: model.NewString("n_" + model.NewId()),
Name: model.NewPointer("n_" + model.NewId()),
DisplayName: "dn_" + model.NewId(),
Source: model.GroupSourceLdap,
RemoteId: model.NewString("ri_" + model.NewId()),
RemoteId: model.NewPointer("ri_" + model.NewId()),
})
require.NoError(t, err)
@@ -5084,10 +5084,10 @@ func testUserStoreGetTeamGroupUsers(t *testing.T, rctx request.CTX, ss store.Sto
var group *model.Group
group, err = ss.Group().Create(&model.Group{
Name: model.NewString("n_" + id),
Name: model.NewPointer("n_" + id),
DisplayName: "dn_" + id,
Source: model.GroupSourceLdap,
RemoteId: model.NewString("ri_" + id),
RemoteId: model.NewPointer("ri_" + id),
})
require.NoError(t, err)
require.NotNil(t, group)
@@ -5123,7 +5123,7 @@ func testUserStoreGetTeamGroupUsers(t *testing.T, rctx request.CTX, ss store.Sto
requireNUsers(1)
// update team to be group-constrained
team.GroupConstrained = model.NewBool(true)
team.GroupConstrained = model.NewPointer(true)
team, err = ss.Team().Update(team)
require.NoError(t, err)
@@ -5205,10 +5205,10 @@ func testUserStoreGetChannelGroupUsers(t *testing.T, rctx request.CTX, ss store.
id = model.NewId()
var group *model.Group
group, err = ss.Group().Create(&model.Group{
Name: model.NewString("n_" + id),
Name: model.NewPointer("n_" + id),
DisplayName: "dn_" + id,
Source: model.GroupSourceLdap,
RemoteId: model.NewString("ri_" + id),
RemoteId: model.NewPointer("ri_" + id),
})
require.NoError(t, err)
require.NotNil(t, group)
@@ -5244,7 +5244,7 @@ func testUserStoreGetChannelGroupUsers(t *testing.T, rctx request.CTX, ss store.
requireNUsers(1)
// update team to be group-constrained
channel.GroupConstrained = model.NewBool(true)
channel.GroupConstrained = model.NewPointer(true)
_, nErr = ss.Channel().Update(rctx, channel)
require.NoError(t, nErr)