Expose public/ API as submodule (#23345)
* model -> public/model * plugin -> public/plugin * public/model/utils -> public/utils * platform/shared/mlog -> public/shared/mlog * platform/shared/i18n -> public/shared/i18n * platform/shared/markdown -> public/shared/markdown * platform/services/timezones -> public/shared/timezones * channels/einterfaces -> einterfaces * expose public/ submodule * go mod tidy * .github: cache-dependency-path, setup-go-work * modules-tidy for public/ too * remove old gomodtidy
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
070ee26081
Коммит
bb02b35048
57
server/public/model/slack_compatibility_test.go
Обычный файл
57
server/public/model/slack_compatibility_test.go
Обычный файл
@@ -0,0 +1,57 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestSlackCompatibleBool_UnmarshalJSON_True(t *testing.T) {
|
||||
cases := []struct {
|
||||
name string
|
||||
payload string
|
||||
}{
|
||||
{name: "literal", payload: `{"title": "Foo", "value": "Bar", "short": true}`},
|
||||
{name: "stringLower", payload: `{"title": "Foo", "value": "Bar", "short": "true"}`},
|
||||
{name: "stringMixed", payload: `{"title": "Foo", "value": "Bar", "short": "True"}`},
|
||||
{name: "stringUpper", payload: `{"title": "Foo", "value": "Bar", "short": "TRUE"}`},
|
||||
}
|
||||
|
||||
for _, tt := range cases {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
field := &SlackAttachmentField{}
|
||||
|
||||
err := json.Unmarshal([]byte(tt.payload), field)
|
||||
|
||||
require.NoError(t, err)
|
||||
require.True(t, bool(field.Short))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestSlackCompatibleBool_UnmarshalJSON_False(t *testing.T) {
|
||||
cases := []struct {
|
||||
name string
|
||||
payload string
|
||||
}{
|
||||
{name: "literal", payload: `{"title": "Foo", "value": "Bar", "short": false}`},
|
||||
{name: "stringLower", payload: `{"title": "Foo", "value": "Bar", "short": "false"}`},
|
||||
{name: "stringMixed", payload: `{"title": "Foo", "value": "Bar", "short": "False"}`},
|
||||
{name: "stringUpper", payload: `{"title": "Foo", "value": "Bar", "short": "FALSE"}`},
|
||||
}
|
||||
|
||||
for _, tt := range cases {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
field := &SlackAttachmentField{}
|
||||
|
||||
err := json.Unmarshal([]byte(tt.payload), field)
|
||||
|
||||
require.NoError(t, err)
|
||||
require.False(t, bool(field.Short))
|
||||
})
|
||||
}
|
||||
}
|
||||
Ссылка в новой задаче
Block a user