[MM-14846] Update EditAt for FileIds and Attachment in Post + Ignore FileIds Updates (#10540)

* Set EditAt for FileIds and Attachments; Disallow update/patch of FileIds in API Handler

* Add custom comparison methods for StringArray and Post Attachments

* gofmt

* Split up comparison function to child structs

* Naming consistency

* gofmt
Этот коммит содержится в:
Daniel Schalla
2019-04-04 20:01:21 +02:00
коммит произвёл GitHub
родитель 41fe33bbb1
Коммит 7c9837d9b1
9 изменённых файлов: 519 добавлений и 4 удалений

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

@@ -250,6 +250,49 @@ var hashtags = map[string]string{
"foo#bar": "",
}
func TestStringArray_Equal(t *testing.T) {
for name, tc := range map[string]struct {
Array1 StringArray
Array2 StringArray
Expected bool
}{
"Empty": {
nil,
nil,
true,
},
"EqualLength_EqualValue": {
StringArray{"123"},
StringArray{"123"},
true,
},
"DifferentLength": {
StringArray{"123"},
StringArray{"123", "abc"},
false,
},
"DifferentValues_EqualLength": {
StringArray{"123"},
StringArray{"abc"},
false,
},
"EqualLength_EqualValues": {
StringArray{"123", "abc"},
StringArray{"123", "abc"},
true,
},
"EqualLength_EqualValues_DifferentOrder": {
StringArray{"abc", "123"},
StringArray{"123", "abc"},
false,
},
} {
t.Run(name, func(t *testing.T) {
assert.Equal(t, tc.Expected, tc.Array1.Equals(tc.Array2))
})
}
}
func TestParseHashtags(t *testing.T) {
for input, output := range hashtags {
if o, _ := ParseHashtags(input); o != output {