* MM-36448: Removes legacy CLI commands. * MM-26448: Update translations. * MM-36448: Fixes some lint errors. * MM-36448: Conflict resolution error fix. Lint fixes. * MM-36448: Removes some more commands. * MM-36448: Removes unused functions. * MM-36448: Re-adds config command. * MM-36448: Re-adds func for use by config. * MM-36448: Moved structs back. * MM-36488: Re-adds version. * MM-36448: Re-added some commands. * MM-36448: Fix tests. * MM-36448: Removed unused func. * MM-36448: Removes test. * MM-36448: Removes uses of 'config set'. * MM-36448: Moves some test structs. * MM-36448: Removes the logs command. * MM-36448: Re-deleted file after bad merge. * MM-36448: Deleted test files again. * MM-36448: Re-delete files. Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
74 строки
1.7 KiB
Go
74 строки
1.7 KiB
Go
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
package commands
|
|
|
|
import (
|
|
"reflect"
|
|
"sort"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestPrintMap(t *testing.T) {
|
|
inputCases := []interface{}{
|
|
map[string]interface{}{
|
|
"CustomerType": "A9",
|
|
"SmtpUsername": "",
|
|
"SmtpPassword": "",
|
|
"EmailAddress": "",
|
|
},
|
|
map[string]interface{}{
|
|
"EnableExport": false,
|
|
"ExportFormat": "actiance",
|
|
"DailyRunTime": "01:00",
|
|
"GlobalRelaySettings": map[string]interface{}{
|
|
"CustomerType": "A9",
|
|
"SmtpUsername": "",
|
|
"SmtpPassword": "",
|
|
"EmailAddress": "",
|
|
},
|
|
},
|
|
}
|
|
|
|
outputCases := []string{
|
|
"CustomerType: \"A9\"\nSmtpUsername: \"\"\nSmtpPassword: \"\"\nEmailAddress: \"\"\n",
|
|
"EnableExport: \"false\"\nExportFormat: \"actiance\"\nDailyRunTime: \"01:00\"\nGlobalRelaySettings:\n\t CustomerType: \"A9\"\n\tSmtpUsername: \"\"\n\tSmtpPassword: \"\"\n\tEmailAddress: \"\"\n",
|
|
}
|
|
|
|
cases := []struct {
|
|
Name string
|
|
Input reflect.Value
|
|
Expected string
|
|
}{
|
|
{
|
|
Name: "Basic print",
|
|
Input: reflect.ValueOf(inputCases[0]),
|
|
Expected: outputCases[0],
|
|
},
|
|
{
|
|
Name: "Complex print",
|
|
Input: reflect.ValueOf(inputCases[1]),
|
|
Expected: outputCases[1],
|
|
},
|
|
}
|
|
|
|
for _, test := range cases {
|
|
t.Run(test.Name, func(t *testing.T) {
|
|
res := printStringMap(test.Input, 0)
|
|
|
|
// create two slice of string formed by splitting our strings on \n
|
|
slice1 := strings.Split(res, "\n")
|
|
slice2 := strings.Split(res, "\n")
|
|
|
|
sort.Strings(slice1)
|
|
sort.Strings(slice2)
|
|
|
|
if !reflect.DeepEqual(slice1, slice2) {
|
|
t.Errorf("got '%#v' want '%#v", slice1, slice2)
|
|
}
|
|
|
|
})
|
|
}
|
|
}
|