mattermost/server/channels/api4/post_utils_test.go
Harshil Sharma 49fdffda8f
Some checks are pending
Server CI / Compute Go Version (push) Waiting to run
Server CI / Check mocks (push) Blocked by required conditions
Server CI / Check go mod tidy (push) Blocked by required conditions
Server CI / check-style (push) Blocked by required conditions
Server CI / Check serialization methods for hot structs (push) Blocked by required conditions
Server CI / Vet API (push) Blocked by required conditions
Server CI / Check migration files (push) Blocked by required conditions
Server CI / Generate email templates (push) Blocked by required conditions
Server CI / Check store layers (push) Blocked by required conditions
Server CI / Check mmctl docs (push) Blocked by required conditions
Server CI / Postgres with binary parameters (push) Blocked by required conditions
Server CI / Postgres (shard 0) (push) Blocked by required conditions
Server CI / Postgres (shard 1) (push) Blocked by required conditions
Server CI / Postgres (shard 2) (push) Blocked by required conditions
Server CI / Postgres (shard 3) (push) Blocked by required conditions
Server CI / Merge Postgres Test Results (push) Blocked by required conditions
Server CI / Postgres FIPS (shard 0) (push) Blocked by required conditions
Server CI / Postgres FIPS (shard 1) (push) Blocked by required conditions
Server CI / Postgres FIPS (shard 2) (push) Blocked by required conditions
Server CI / Postgres FIPS (shard 3) (push) Blocked by required conditions
Server CI / Merge Postgres FIPS Test Results (push) Blocked by required conditions
Server CI / Generate Test Coverage (push) Blocked by required conditions
Server CI / Run mmctl tests (push) Blocked by required conditions
Server CI / Run mmctl tests (FIPS) (push) Blocked by required conditions
Server CI / Build mattermost server app (push) Blocked by required conditions
Web App CI / check-lint (push) Waiting to run
Web App CI / check-i18n (push) Blocked by required conditions
Web App CI / check-external-links (push) Blocked by required conditions
Web App CI / check-types (push) Blocked by required conditions
Web App CI / test (platform) (push) Blocked by required conditions
Web App CI / test (mattermost-redux) (push) Blocked by required conditions
Web App CI / test (channels shard 1/4) (push) Blocked by required conditions
Web App CI / test (channels shard 2/4) (push) Blocked by required conditions
Web App CI / test (channels shard 3/4) (push) Blocked by required conditions
Web App CI / test (channels shard 4/4) (push) Blocked by required conditions
Web App CI / upload-coverage (push) Blocked by required conditions
Web App CI / build (push) Blocked by required conditions
Edit attachment permission (#36227) (#36727)
Automatic Merge
2026-05-25 12:24:15 +02:00

94 lines
2 KiB
Go

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
package api4
import (
"testing"
"github.com/mattermost/mattermost/server/v8/channels/utils"
"github.com/stretchr/testify/assert"
)
func TestSameFileIDs(t *testing.T) {
tests := []struct {
name string
a []string
b []string
expected bool
}{
{
name: "both empty",
a: []string{},
b: []string{},
expected: true,
},
{
name: "both nil",
a: nil,
b: nil,
expected: true,
},
{
name: "same files same order",
a: []string{"file1", "file2", "file3"},
b: []string{"file1", "file2", "file3"},
expected: true,
},
{
name: "same files different order",
a: []string{"file3", "file1", "file2"},
b: []string{"file1", "file2", "file3"},
expected: true,
},
{
name: "one file added",
a: []string{"file1", "file2", "file3"},
b: []string{"file1", "file2"},
expected: false,
},
{
name: "one file removed",
a: []string{"file1"},
b: []string{"file1", "file2"},
expected: false,
},
{
name: "different files same length",
a: []string{"file1", "file2"},
b: []string{"file1", "file3"},
expected: false,
},
{
name: "duplicate IDs in a",
a: []string{"file1", "file1"},
b: []string{"file1", "file2"},
expected: false,
},
{
name: "duplicate IDs same in both",
a: []string{"file1", "file1"},
b: []string{"file1", "file1"},
expected: true,
},
{
name: "empty vs non-empty",
a: []string{},
b: []string{"file1"},
expected: false,
},
{
name: "nil vs non-empty",
a: nil,
b: []string{"file1"},
expected: false,
},
}
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
result := utils.SliceEqualUnordered(tc.a, tc.b)
assert.Equal(t, tc.expected, result)
})
}
}