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

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

@@ -233,7 +233,7 @@ func TestCreatePost(t *testing.T) {
t.Run("Should not be able to define the RemoteId of a post from the API", func(t *testing.T) {
newPost := &model.Post{
RemoteId: model.NewString(model.NewId()),
RemoteId: model.NewPointer(model.NewId()),
ChannelId: th.BasicChannel.Id,
Message: "post content " + model.NewId(),
DeleteAt: 0,
@@ -273,7 +273,7 @@ func TestCreatePostForPriority(t *testing.T) {
post := &model.Post{ChannelId: th.BasicChannel.Id, Message: "test", Metadata: &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString("urgent"),
Priority: model.NewPointer("urgent"),
},
}}
@@ -291,7 +291,7 @@ func TestCreatePostForPriority(t *testing.T) {
replyPost := &model.Post{RootId: post.Id, ChannelId: th.BasicChannel.Id, Message: "reply", Metadata: &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString("urgent"),
Priority: model.NewPointer("urgent"),
},
}}
_, resp, err = client.CreatePost(context.Background(), replyPost)
@@ -305,8 +305,8 @@ func TestCreatePostForPriority(t *testing.T) {
// for Acknowledment
p1 := &model.Post{ChannelId: th.BasicChannel.Id, Message: "test", Metadata: &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString("urgent"),
RequestedAck: model.NewBool(true),
Priority: model.NewPointer("urgent"),
RequestedAck: model.NewPointer(true),
},
}}
_, resp, err := client.CreatePost(context.Background(), p1)
@@ -316,8 +316,8 @@ func TestCreatePostForPriority(t *testing.T) {
// for Persistent Notification
p2 := &model.Post{ChannelId: th.BasicChannel.Id, Message: "test", Metadata: &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString("urgent"),
PersistentNotifications: model.NewBool(true),
Priority: model.NewPointer("urgent"),
PersistentNotifications: model.NewPointer(true),
},
}}
_, resp, err = client.CreatePost(context.Background(), p2)
@@ -337,8 +337,8 @@ func TestCreatePostForPriority(t *testing.T) {
p1 := &model.Post{ChannelId: th.BasicChannel.Id, Message: "test", Metadata: &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString("urgent"),
PersistentNotifications: model.NewBool(true),
Priority: model.NewPointer("urgent"),
PersistentNotifications: model.NewPointer(true),
},
}}
_, resp, err := client.CreatePost(context.Background(), p1)
@@ -349,8 +349,8 @@ func TestCreatePostForPriority(t *testing.T) {
t.Run("should return badRequest when post is not urgent for persistent notification", func(t *testing.T) {
p1 := &model.Post{ChannelId: th.BasicChannel.Id, Message: "test", Metadata: &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString("important"),
PersistentNotifications: model.NewBool(true),
Priority: model.NewPointer("important"),
PersistentNotifications: model.NewPointer(true),
},
}}
_, resp, err := client.CreatePost(context.Background(), p1)
@@ -373,8 +373,8 @@ func TestCreatePostForPriority(t *testing.T) {
p1 := &model.Post{ChannelId: th.BasicChannel.Id, Message: "test", Metadata: &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString("urgent"),
PersistentNotifications: model.NewBool(true),
Priority: model.NewPointer("urgent"),
PersistentNotifications: model.NewPointer(true),
},
}}
_, resp, err := client.CreatePost(context.Background(), p1)
@@ -385,7 +385,7 @@ func TestCreatePostForPriority(t *testing.T) {
t.Run("should create priority post", func(t *testing.T) {
p1 := &model.Post{ChannelId: th.BasicChannel.Id, Message: "test", Metadata: &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString("important"),
Priority: model.NewPointer("important"),
},
}}
_, resp, err := client.CreatePost(context.Background(), p1)
@@ -396,8 +396,8 @@ func TestCreatePostForPriority(t *testing.T) {
t.Run("should create acknowledge post", func(t *testing.T) {
p1 := &model.Post{ChannelId: th.BasicChannel.Id, Message: "test", Metadata: &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString(""),
RequestedAck: model.NewBool(true),
Priority: model.NewPointer(""),
RequestedAck: model.NewPointer(true),
},
}}
_, resp, err := client.CreatePost(context.Background(), p1)
@@ -408,9 +408,9 @@ func TestCreatePostForPriority(t *testing.T) {
t.Run("should create persistent notification post", func(t *testing.T) {
p1 := &model.Post{ChannelId: th.BasicChannel.Id, Message: "test @" + th.BasicUser2.Username, Metadata: &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString("urgent"),
RequestedAck: model.NewBool(false),
PersistentNotifications: model.NewBool(true),
Priority: model.NewPointer("urgent"),
RequestedAck: model.NewPointer(false),
PersistentNotifications: model.NewPointer(true),
},
}}
_, resp, err := client.CreatePost(context.Background(), p1)
@@ -615,7 +615,7 @@ func testCreatePostWithOutgoingHook(
}
outGoingHookResponse := &model.OutgoingWebhookResponse{
Text: model.NewString("some test text"),
Text: model.NewPointer("some test text"),
Username: "TestCommandServer",
IconURL: "https://mattermost.com/wp-content/uploads/2022/02/icon.png",
Type: "custom_as",
@@ -1532,12 +1532,12 @@ func TestPatchPost(t *testing.T) {
t.Run("new message, props, files, HasReactions bit", func(t *testing.T) {
patch := &model.PostPatch{}
patch.IsPinned = model.NewBool(false)
patch.Message = model.NewString("#otherhashtag other message")
patch.IsPinned = model.NewPointer(false)
patch.Message = model.NewPointer("#otherhashtag other message")
patch.Props = &model.StringInterface{"channel_header": "new_header"}
patchFileIds := model.StringArray(fileIDs) // one extra file
patch.FileIds = &patchFileIds
patch.HasReactions = model.NewBool(false)
patch.HasReactions = model.NewPointer(false)
rpost, _, err = client.PatchPost(context.Background(), post.Id, patch)
require.NoError(t, err)
@@ -1655,7 +1655,7 @@ func TestPatchPost(t *testing.T) {
require.NoError(t, err)
patch2 := &model.PostPatch{
Message: model.NewString("new message"),
Message: model.NewPointer("new message"),
}
_, resp, err := th.SystemAdminClient.PatchPost(context.Background(), post2.Id, patch2)
require.Error(t, err)
@@ -3757,7 +3757,7 @@ func TestGetEditHistoryForPost(t *testing.T) {
// update the post message
patch := &model.PostPatch{
Message: model.NewString("new message edited"),
Message: model.NewPointer("new message edited"),
}
// Patch the post
@@ -3767,7 +3767,7 @@ func TestGetEditHistoryForPost(t *testing.T) {
// update the post message again
patch = &model.PostPatch{
Message: model.NewString("new message edited again"),
Message: model.NewPointer("new message edited again"),
}
_, response2, err2 := client.PatchPost(context.Background(), rpost.Id, patch)