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 удалений

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

@@ -139,7 +139,7 @@ func TestCreateChannel(t *testing.T) {
require.Equal(t, http.StatusBadRequest, r.StatusCode, "Expected 400 Bad Request")
// Test GroupConstrained flag
groupConstrainedChannel := &model.Channel{DisplayName: "Test API Name", Name: GenerateTestChannelName(), Type: model.ChannelTypeOpen, TeamId: team.Id, GroupConstrained: model.NewBool(true)}
groupConstrainedChannel := &model.Channel{DisplayName: "Test API Name", Name: GenerateTestChannelName(), Type: model.ChannelTypeOpen, TeamId: team.Id, GroupConstrained: model.NewPointer(true)}
rchannel, _, err = client.CreateChannel(context.Background(), groupConstrainedChannel)
require.NoError(t, err)
@@ -187,7 +187,7 @@ func TestUpdateChannel(t *testing.T) {
require.Equal(t, channel.Purpose, newChannel.Purpose, "Update failed for Purpose")
// Test GroupConstrained flag
channel.GroupConstrained = model.NewBool(true)
channel.GroupConstrained = model.NewPointer(true)
rchannel, resp, err := client.UpdateChannel(context.Background(), channel)
require.NoError(t, err)
CheckOKStatus(t, resp)
@@ -386,7 +386,7 @@ func TestPatchChannel(t *testing.T) {
CheckBadRequestStatus(t, resp)
// Test GroupConstrained flag
patch.GroupConstrained = model.NewBool(true)
patch.GroupConstrained = model.NewPointer(true)
rchannel, resp, err := client.PatchChannel(context.Background(), th.BasicChannel.Id, patch)
require.NoError(t, err)
CheckOKStatus(t, resp)
@@ -1351,7 +1351,7 @@ func TestGetAllChannels(t *testing.T) {
policy, err := th.App.Srv().Store().RetentionPolicy().Save(&model.RetentionPolicyWithTeamAndChannelIDs{
RetentionPolicy: model.RetentionPolicy{
DisplayName: "Policy 1",
PostDurationDays: model.NewInt64(30),
PostDurationDays: model.NewPointer(int64(30)),
},
ChannelIDs: []string{policyChannel.Id},
})
@@ -1698,7 +1698,7 @@ func TestSearchAllChannels(t *testing.T) {
DisplayName: "SearchAllChannels-groupConstrained-1",
Name: "groupconstrained1",
Type: model.ChannelTypePrivate,
GroupConstrained: model.NewBool(true),
GroupConstrained: model.NewPointer(true),
TeamId: team.Id,
})
require.NoError(t, err)
@@ -1853,7 +1853,7 @@ func TestSearchAllChannels(t *testing.T) {
policy, savePolicyErr := th.App.Srv().Store().RetentionPolicy().Save(&model.RetentionPolicyWithTeamAndChannelIDs{
RetentionPolicy: model.RetentionPolicy{
DisplayName: "Policy 1",
PostDurationDays: model.NewInt64(30),
PostDurationDays: model.NewPointer(int64(30)),
},
ChannelIDs: []string{policyChannel.Id},
})
@@ -1896,8 +1896,8 @@ func TestSearchAllChannelsPaged(t *testing.T) {
search := &model.ChannelSearch{Term: th.BasicChannel.Name}
search.Term = ""
search.Page = model.NewInt(0)
search.PerPage = model.NewInt(2)
search.Page = model.NewPointer(0)
search.PerPage = model.NewPointer(2)
channelsWithCount, _, err := th.SystemAdminClient.SearchAllChannelsPaged(context.Background(), search)
require.NoError(t, err)
require.Len(t, channelsWithCount.Channels, 2)
@@ -3369,7 +3369,7 @@ func TestAddChannelMember(t *testing.T) {
client.Logout(context.Background())
// Set a channel to group-constrained
privateChannel.GroupConstrained = model.NewBool(true)
privateChannel.GroupConstrained = model.NewPointer(true)
_, appErr := th.App.UpdateChannel(th.Context, privateChannel)
require.Nil(t, appErr)
@@ -3780,7 +3780,7 @@ func TestRemoveChannelMember(t *testing.T) {
require.NoError(t, err)
// If the channel is group-constrained the user cannot be removed
privateChannel.GroupConstrained = model.NewBool(true)
privateChannel.GroupConstrained = model.NewPointer(true)
_, appErr := th.App.UpdateChannel(th.Context, privateChannel)
require.Nil(t, appErr)
_, err = client.RemoveUserFromChannel(context.Background(), privateChannel.Id, user2.Id)
@@ -4272,7 +4272,7 @@ func TestChannelMembersMinusGroupMembers(t *testing.T) {
_, appErr = th.App.AddChannelMember(th.Context, user2.Id, channel, app.ChannelMemberOpts{})
require.Nil(t, appErr)
channel.GroupConstrained = model.NewBool(true)
channel.GroupConstrained = model.NewPointer(true)
channel, appErr = th.App.UpdateChannel(th.Context, channel)
require.Nil(t, appErr)
@@ -4615,7 +4615,7 @@ func TestPatchChannelModerations(t *testing.T) {
patch := []*model.ChannelModerationPatch{
{
Name: &createPosts,
Roles: &model.ChannelModeratedRolesPatch{Members: model.NewBool(false)},
Roles: &model.ChannelModeratedRolesPatch{Members: model.NewPointer(false)},
},
}
@@ -4652,7 +4652,7 @@ func TestPatchChannelModerations(t *testing.T) {
patch := []*model.ChannelModerationPatch{
{
Name: &createPosts,
Roles: &model.ChannelModeratedRolesPatch{Members: model.NewBool(true)},
Roles: &model.ChannelModeratedRolesPatch{Members: model.NewPointer(true)},
},
}
@@ -4729,7 +4729,7 @@ func TestPatchChannelModerations(t *testing.T) {
patch := []*model.ChannelModerationPatch{
{
Name: &createPosts,
Roles: &model.ChannelModeratedRolesPatch{Members: model.NewBool(true)},
Roles: &model.ChannelModeratedRolesPatch{Members: model.NewPointer(true)},
},
}
@@ -4814,9 +4814,9 @@ func TestGetChannelMemberCountsByGroup(t *testing.T) {
id := model.NewId()
group := &model.Group{
DisplayName: "dn_" + id,
Name: model.NewString("name" + id),
Name: model.NewPointer("name" + id),
Source: model.GroupSourceLdap,
RemoteId: model.NewString(model.NewId()),
RemoteId: model.NewPointer(model.NewId()),
}
_, appErr = th.App.CreateGroup(group)