Merge branch 'master' into mark-as-unread
Этот коммит содержится в:
@@ -17,9 +17,9 @@ func TestClient4CreatePost(t *testing.T) {
|
||||
post := &Post{
|
||||
Props: map[string]interface{}{
|
||||
"attachments": []*SlackAttachment{
|
||||
&SlackAttachment{
|
||||
{
|
||||
Actions: []*PostAction{
|
||||
&PostAction{
|
||||
{
|
||||
Integration: &PostActionIntegration{
|
||||
Context: map[string]interface{}{
|
||||
"foo": "bar",
|
||||
@@ -37,9 +37,9 @@ func TestClient4CreatePost(t *testing.T) {
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
attachments := PostFromJson(r.Body).Attachments()
|
||||
assert.Equal(t, []*SlackAttachment{
|
||||
&SlackAttachment{
|
||||
{
|
||||
Actions: []*PostAction{
|
||||
&PostAction{
|
||||
{
|
||||
Integration: &PostActionIntegration{
|
||||
Context: map[string]interface{}{
|
||||
"foo": "bar",
|
||||
|
||||
@@ -146,7 +146,7 @@ func TestCommandResponseFromJson(t *testing.T) {
|
||||
&CommandResponse{
|
||||
Text: "message 1",
|
||||
ExtraResponses: []*CommandResponse{
|
||||
&CommandResponse{
|
||||
{
|
||||
Text: "message 2",
|
||||
},
|
||||
},
|
||||
@@ -180,7 +180,7 @@ func TestCommandResponseFromJson(t *testing.T) {
|
||||
},
|
||||
},
|
||||
ExtraResponses: []*CommandResponse{
|
||||
&CommandResponse{
|
||||
{
|
||||
Text: "message 2",
|
||||
Attachments: []*SlackAttachment{
|
||||
{
|
||||
|
||||
@@ -325,6 +325,7 @@ type ServiceSettings struct {
|
||||
DisableBotsWhenOwnerIsDeactivated *bool `restricted:"true"`
|
||||
EnableBotAccountCreation *bool
|
||||
EnableSVGs *bool
|
||||
EnableLatex *bool
|
||||
}
|
||||
|
||||
func (s *ServiceSettings) SetDefaults(isUpdate bool) {
|
||||
@@ -689,6 +690,14 @@ func (s *ServiceSettings) SetDefaults(isUpdate bool) {
|
||||
s.EnableSVGs = NewBool(false)
|
||||
}
|
||||
}
|
||||
|
||||
if s.EnableLatex == nil {
|
||||
if isUpdate {
|
||||
s.EnableLatex = NewBool(true)
|
||||
} else {
|
||||
s.EnableLatex = NewBool(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
type ClusterSettings struct {
|
||||
@@ -2871,7 +2880,7 @@ func (ss *ServiceSettings) isValid() *AppError {
|
||||
return NewAppError("Config.IsValid", "model.config.is_valid.webserver_security.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if *ss.ConnectionSecurity == CONN_SECURITY_TLS && *ss.UseLetsEncrypt == false {
|
||||
if *ss.ConnectionSecurity == CONN_SECURITY_TLS && !*ss.UseLetsEncrypt {
|
||||
appErr := NewAppError("Config.IsValid", "model.config.is_valid.tls_cert_file.app_error", nil, "", http.StatusBadRequest)
|
||||
|
||||
if *ss.TLSCertFile == "" {
|
||||
|
||||
@@ -186,7 +186,6 @@ func TestConfigIsValidFakeAlgorithm(t *testing.T) {
|
||||
require.Equal(t, "model.config.is_valid.saml_digest_algorithm.app_error", err.Message)
|
||||
*c1.SamlSettings.DigestAlgorithm = temp
|
||||
|
||||
temp = *c1.SamlSettings.SignatureAlgorithm
|
||||
*c1.SamlSettings.SignatureAlgorithm = "Fake Algorithm"
|
||||
err = c1.SamlSettings.isValid()
|
||||
if err == nil {
|
||||
|
||||
@@ -5,6 +5,8 @@ package model
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
_ "image/gif"
|
||||
_ "image/png"
|
||||
"io/ioutil"
|
||||
@@ -22,179 +24,109 @@ func TestFileInfoIsValid(t *testing.T) {
|
||||
Path: "fake/path.png",
|
||||
}
|
||||
|
||||
if err := info.IsValid(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
require.Nil(t, info.IsValid())
|
||||
|
||||
info.Id = ""
|
||||
if err := info.IsValid(); err == nil {
|
||||
t.Fatal("empty Id isn't valid")
|
||||
}
|
||||
require.NotNil(t, info.IsValid(), "empty Id isn't valid")
|
||||
|
||||
info.Id = NewId()
|
||||
info.CreateAt = 0
|
||||
if err := info.IsValid(); err == nil {
|
||||
t.Fatal("empty CreateAt isn't valid")
|
||||
}
|
||||
require.NotNil(t, info.IsValid(), "empty CreateAt isn't valid")
|
||||
|
||||
info.CreateAt = 1234
|
||||
info.UpdateAt = 0
|
||||
if err := info.IsValid(); err == nil {
|
||||
t.Fatal("empty UpdateAt isn't valid")
|
||||
}
|
||||
require.NotNil(t, info.IsValid(), "empty UpdateAt isn't valid")
|
||||
|
||||
info.UpdateAt = 1234
|
||||
info.PostId = NewId()
|
||||
if err := info.IsValid(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
require.Nil(t, info.IsValid())
|
||||
|
||||
info.Path = ""
|
||||
if err := info.IsValid(); err == nil {
|
||||
t.Fatal("empty Path isn't valid")
|
||||
}
|
||||
require.NotNil(t, info.IsValid(), "empty Path isn't valid")
|
||||
|
||||
info.Path = "fake/path.png"
|
||||
if err := info.IsValid(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
require.Nil(t, info.IsValid())
|
||||
}
|
||||
|
||||
func TestFileInfoIsImage(t *testing.T) {
|
||||
info := &FileInfo{
|
||||
MimeType: "image/png",
|
||||
}
|
||||
|
||||
if !info.IsImage() {
|
||||
t.Fatal("file is an image")
|
||||
}
|
||||
info := &FileInfo{MimeType: "image/png"}
|
||||
assert.True(t, info.IsImage(), "file is an image")
|
||||
|
||||
info.MimeType = "text/plain"
|
||||
if info.IsImage() {
|
||||
t.Fatal("file is not an image")
|
||||
}
|
||||
assert.False(t, info.IsImage(), "file is not an image")
|
||||
}
|
||||
|
||||
func TestGetInfoForFile(t *testing.T) {
|
||||
fakeFile := make([]byte, 1000)
|
||||
|
||||
if info, err := GetInfoForBytes("file.txt", fakeFile); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if info.Name != "file.txt" {
|
||||
t.Fatalf("Got incorrect filename: %v", info.Name)
|
||||
} else if info.Extension != "txt" {
|
||||
t.Fatalf("Got incorrect extension: %v", info.Extension)
|
||||
} else if info.Size != 1000 {
|
||||
t.Fatalf("Got incorrect size: %v", info.Size)
|
||||
} else if !strings.HasPrefix(info.MimeType, "text/plain") {
|
||||
t.Fatalf("Got incorrect mime type: %v", info.MimeType)
|
||||
} else if info.Width != 0 {
|
||||
t.Fatalf("Got incorrect width: %v", info.Width)
|
||||
} else if info.Height != 0 {
|
||||
t.Fatalf("Got incorrect height: %v", info.Height)
|
||||
} else if info.HasPreviewImage {
|
||||
t.Fatalf("Got incorrect has preview image: %v", info.HasPreviewImage)
|
||||
}
|
||||
info, errApp := GetInfoForBytes("file.txt", fakeFile)
|
||||
require.Nil(t, errApp)
|
||||
assert.Equalf(t, info.Name, "file.txt", "Got incorrect filename: %v", info.Name)
|
||||
assert.Equalf(t, info.Extension, "txt", "Got incorrect extension: %v", info.Extension)
|
||||
assert.EqualValuesf(t, info.Size, 1000, "Got incorrect size: %v", info.Size)
|
||||
assert.Truef(t, strings.HasPrefix(info.MimeType, "text/plain"), "Got incorrect mime type: %v", info.MimeType)
|
||||
assert.Equalf(t, info.Width, 0, "Got incorrect width: %v", info.Width)
|
||||
assert.Equalf(t, info.Height, 0, "Got incorrect height: %v", info.Height)
|
||||
assert.Falsef(t, info.HasPreviewImage, "Got incorrect has preview image: %v", info.HasPreviewImage)
|
||||
|
||||
pngFile, err := ioutil.ReadFile("../tests/test.png")
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to load test.png: %v", err.Error())
|
||||
}
|
||||
if info, err := GetInfoForBytes("test.png", pngFile); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if info.Name != "test.png" {
|
||||
t.Fatalf("Got incorrect filename: %v", info.Name)
|
||||
} else if info.Extension != "png" {
|
||||
t.Fatalf("Got incorrect extension: %v", info.Extension)
|
||||
} else if info.Size != 279591 {
|
||||
t.Fatalf("Got incorrect size: %v", info.Size)
|
||||
} else if info.MimeType != "image/png" {
|
||||
t.Fatalf("Got incorrect mime type: %v", info.MimeType)
|
||||
} else if info.Width != 408 {
|
||||
t.Fatalf("Got incorrect width: %v", info.Width)
|
||||
} else if info.Height != 336 {
|
||||
t.Fatalf("Got incorrect height: %v", info.Height)
|
||||
} else if !info.HasPreviewImage {
|
||||
t.Fatalf("Got incorrect has preview image: %v", info.HasPreviewImage)
|
||||
}
|
||||
require.Nilf(t, err, "Failed to load test.png")
|
||||
|
||||
info, err = GetInfoForBytes("test.png", pngFile)
|
||||
require.Nil(t, err)
|
||||
assert.Equalf(t, info.Name, "test.png", "Got incorrect filename: %v", info.Name)
|
||||
assert.Equalf(t, info.Extension, "png", "Got incorrect extension: %v", info.Extension)
|
||||
assert.EqualValues(t, info.Size, 279591, "Got incorrect size: %v", info.Size)
|
||||
assert.Equalf(t, info.MimeType, "image/png", "Got incorrect mime type: %v", info.MimeType)
|
||||
assert.Equalf(t, info.Width, 408, "Got incorrect width: %v", info.Width)
|
||||
assert.Equalf(t, info.Height, 336, "Got incorrect height: %v", info.Height)
|
||||
assert.Truef(t, info.HasPreviewImage, "Got incorrect has preview image: %v", info.HasPreviewImage)
|
||||
|
||||
// base 64 encoded version of handtinywhite.gif from http://probablyprogramming.com/2009/03/15/the-tiniest-gif-ever
|
||||
gifFile, _ := base64.StdEncoding.DecodeString("R0lGODlhAQABAIABAP///wAAACwAAAAAAQABAAACAkQBADs=")
|
||||
if info, err := GetInfoForBytes("handtinywhite.gif", gifFile); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if info.Name != "handtinywhite.gif" {
|
||||
t.Fatalf("Got incorrect filename: %v", info.Name)
|
||||
} else if info.Extension != "gif" {
|
||||
t.Fatalf("Got incorrect extension: %v", info.Extension)
|
||||
} else if info.Size != 35 {
|
||||
t.Fatalf("Got incorrect size: %v", info.Size)
|
||||
} else if info.MimeType != "image/gif" {
|
||||
t.Fatalf("Got incorrect mime type: %v", info.MimeType)
|
||||
} else if info.Width != 1 {
|
||||
t.Fatalf("Got incorrect width: %v", info.Width)
|
||||
} else if info.Height != 1 {
|
||||
t.Fatalf("Got incorrect height: %v", info.Height)
|
||||
} else if !info.HasPreviewImage {
|
||||
t.Fatalf("Got incorrect has preview image: %v", info.HasPreviewImage)
|
||||
}
|
||||
info, err = GetInfoForBytes("handtinywhite.gif", gifFile)
|
||||
require.Nil(t, err)
|
||||
assert.Equalf(t, info.Name, "handtinywhite.gif", "Got incorrect filename: %v", info.Name)
|
||||
assert.Equalf(t, info.Extension, "gif", "Got incorrect extension: %v", info.Extension)
|
||||
assert.EqualValuesf(t, info.Size, 35, "Got incorrect size: %v", info.Size)
|
||||
assert.Equalf(t, info.MimeType, "image/gif", "Got incorrect mime type: %v", info.MimeType)
|
||||
assert.Equalf(t, info.Width, 1, "Got incorrect width: %v", info.Width)
|
||||
assert.Equalf(t, info.Height, 1, "Got incorrect height: %v", info.Height)
|
||||
assert.Truef(t, info.HasPreviewImage, "Got incorrect has preview image: %v", info.HasPreviewImage)
|
||||
|
||||
animatedGifFile, err := ioutil.ReadFile("../tests/testgif.gif")
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to load testgif.gif: %v", err.Error())
|
||||
}
|
||||
if info, err := GetInfoForBytes("testgif.gif", animatedGifFile); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if info.Name != "testgif.gif" {
|
||||
t.Fatalf("Got incorrect filename: %v", info.Name)
|
||||
} else if info.Extension != "gif" {
|
||||
t.Fatalf("Got incorrect extension: %v", info.Extension)
|
||||
} else if info.Size != 38689 {
|
||||
t.Fatalf("Got incorrect size: %v", info.Size)
|
||||
} else if info.MimeType != "image/gif" {
|
||||
t.Fatalf("Got incorrect mime type: %v", info.MimeType)
|
||||
} else if info.Width != 118 {
|
||||
t.Fatalf("Got incorrect width: %v", info.Width)
|
||||
} else if info.Height != 118 {
|
||||
t.Fatalf("Got incorrect height: %v", info.Height)
|
||||
} else if info.HasPreviewImage {
|
||||
t.Fatalf("Got incorrect has preview image: %v", info.HasPreviewImage)
|
||||
}
|
||||
require.Nilf(t, err, "Failed to load testgif.gif")
|
||||
|
||||
if info, err := GetInfoForBytes("filewithoutextension", fakeFile); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if info.Name != "filewithoutextension" {
|
||||
t.Fatalf("Got incorrect filename: %v", info.Name)
|
||||
} else if info.Extension != "" {
|
||||
t.Fatalf("Got incorrect extension: %v", info.Extension)
|
||||
} else if info.Size != 1000 {
|
||||
t.Fatalf("Got incorrect size: %v", info.Size)
|
||||
} else if info.MimeType != "" {
|
||||
t.Fatalf("Got incorrect mime type: %v", info.MimeType)
|
||||
} else if info.Width != 0 {
|
||||
t.Fatalf("Got incorrect width: %v", info.Width)
|
||||
} else if info.Height != 0 {
|
||||
t.Fatalf("Got incorrect height: %v", info.Height)
|
||||
} else if info.HasPreviewImage {
|
||||
t.Fatalf("Got incorrect has preview image: %v", info.HasPreviewImage)
|
||||
}
|
||||
info, err = GetInfoForBytes("testgif.gif", animatedGifFile)
|
||||
require.Nil(t, err)
|
||||
assert.Equalf(t, info.Name, "testgif.gif", "Got incorrect filename: %v", info.Name)
|
||||
assert.Equalf(t, info.Extension, "gif", "Got incorrect extension: %v", info.Extension)
|
||||
assert.EqualValuesf(t, info.Size, 38689, "Got incorrect size: %v", info.Size)
|
||||
assert.Equalf(t, info.MimeType, "image/gif", "Got incorrect mime type: %v", info.MimeType)
|
||||
assert.Equalf(t, info.Width, 118, "Got incorrect width: %v", info.Width)
|
||||
assert.Equalf(t, info.Height, 118, "Got incorrect height: %v", info.Height)
|
||||
assert.Falsef(t, info.HasPreviewImage, "Got incorrect has preview image: %v", info.HasPreviewImage)
|
||||
|
||||
info, err = GetInfoForBytes("filewithoutextension", fakeFile)
|
||||
require.Nil(t, err)
|
||||
assert.Equalf(t, info.Name, "filewithoutextension", "Got incorrect filename: %v", info.Name)
|
||||
assert.Equalf(t, info.Extension, "", "Got incorrect extension: %v", info.Extension)
|
||||
assert.EqualValuesf(t, info.Size, 1000, "Got incorrect size: %v", info.Size)
|
||||
assert.Equalf(t, info.MimeType, "", "Got incorrect mime type: %v", info.MimeType)
|
||||
assert.Equalf(t, info.Width, 0, "Got incorrect width: %v", info.Width)
|
||||
assert.Equalf(t, info.Height, 0, "Got incorrect height: %v", info.Height)
|
||||
assert.Falsef(t, info.HasPreviewImage, "Got incorrect has preview image: %v", info.HasPreviewImage)
|
||||
|
||||
// Always make the extension lower case to make it easier to use in other places
|
||||
if info, err := GetInfoForBytes("file.TXT", fakeFile); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if info.Name != "file.TXT" {
|
||||
t.Fatalf("Got incorrect filename: %v", info.Name)
|
||||
} else if info.Extension != "txt" {
|
||||
t.Fatalf("Got incorrect extension: %v", info.Extension)
|
||||
}
|
||||
info, err = GetInfoForBytes("file.TXT", fakeFile)
|
||||
require.Nil(t, err)
|
||||
assert.Equalf(t, info.Name, "file.TXT", "Got incorrect filename: %v", info.Name)
|
||||
assert.Equalf(t, info.Extension, "txt", "Got incorrect extension: %v", info.Extension)
|
||||
|
||||
// Don't error out for image formats we don't support
|
||||
if info, err := GetInfoForBytes("file.tif", fakeFile); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if info.Name != "file.tif" {
|
||||
t.Fatalf("Got incorrect filename: %v", info.Name)
|
||||
} else if info.Extension != "tif" {
|
||||
t.Fatalf("Got incorrect extension: %v", info.Extension)
|
||||
} else if info.MimeType != "image/tiff" && info.MimeType != "image/x-tiff" {
|
||||
t.Fatalf("Got incorrect mime type: %v", info.MimeType)
|
||||
}
|
||||
info, err = GetInfoForBytes("file.tif", fakeFile)
|
||||
require.Nil(t, err)
|
||||
assert.Equalf(t, info.Name, "file.tif", "Got incorrect filename: %v", info.Name)
|
||||
assert.Equalf(t, info.Extension, "tif", "Got incorrect extension: %v", info.Extension)
|
||||
assert.True(t, info.MimeType == "image/x-tiff" || info.MimeType == "image/tiff", "Got incorrect mime type: %v", info.MimeType)
|
||||
}
|
||||
|
||||
@@ -284,7 +284,7 @@ func DecodeAndVerifyTriggerId(triggerId string, s *ecdsa.PrivateKey) (string, st
|
||||
R, S *big.Int
|
||||
}
|
||||
|
||||
if _, err := asn1.Unmarshal([]byte(signature), &esig); err != nil {
|
||||
if _, err := asn1.Unmarshal(signature, &esig); err != nil {
|
||||
return "", "", NewAppError("DecodeAndVerifyTriggerId", "interactive_message.decode_trigger_id.signature_decode_failed", nil, err.Error(), http.StatusBadRequest)
|
||||
}
|
||||
|
||||
|
||||
@@ -305,8 +305,8 @@ func TestTruncateOpenGraph(t *testing.T) {
|
||||
sampleImage("metoo.gif"),
|
||||
sampleImage("fifth.ico"),
|
||||
sampleImage("notme.tiff")},
|
||||
Audios: []*opengraph.Audio{&opengraph.Audio{}},
|
||||
Videos: []*opengraph.Video{&opengraph.Video{}},
|
||||
Audios: []*opengraph.Audio{{}},
|
||||
Videos: []*opengraph.Video{{}},
|
||||
Article: &opengraph.Article{},
|
||||
Book: &opengraph.Book{},
|
||||
Profile: &opengraph.Profile{},
|
||||
|
||||
@@ -130,6 +130,12 @@ type Manifest struct {
|
||||
// A description of what your plugin is and does.
|
||||
Description string `json:"description,omitempty" yaml:"description,omitempty"`
|
||||
|
||||
// HomepageURL is an optional link to learn more about the plugin.
|
||||
HomepageURL string `json:"homepage_url,omitempty" yaml:"homepage_url,omitempty"`
|
||||
|
||||
// SupportURL is an optional URL where plugin issues can be reported.
|
||||
SupportURL string `json:"support_url,omitempty" yaml:"support_url,omitempty"`
|
||||
|
||||
// A relative file path in the bundle that points to the plugins svg icon for use with the Plugin Marketplace.
|
||||
// This should be relative to the root of your bundle and the location of the manifest file. Bitmap image formats are not supported.
|
||||
IconPath string `json:"icon_path,omitempty" yaml:"icon_path,omitempty"`
|
||||
|
||||
@@ -64,6 +64,8 @@ func TestFindManifest(t *testing.T) {
|
||||
func TestManifestUnmarshal(t *testing.T) {
|
||||
expected := Manifest{
|
||||
Id: "theid",
|
||||
HomepageURL: "https://example.com",
|
||||
SupportURL: "https://example.com/support",
|
||||
IconPath: "assets/icon.svg",
|
||||
MinServerVersion: "5.6.0",
|
||||
Server: &ManifestServer{
|
||||
@@ -81,7 +83,7 @@ func TestManifestUnmarshal(t *testing.T) {
|
||||
Header: "theheadertext",
|
||||
Footer: "thefootertext",
|
||||
Settings: []*PluginSetting{
|
||||
&PluginSetting{
|
||||
{
|
||||
Key: "thesetting",
|
||||
DisplayName: "thedisplayname",
|
||||
Type: "dropdown",
|
||||
@@ -89,7 +91,7 @@ func TestManifestUnmarshal(t *testing.T) {
|
||||
RegenerateHelpText: "theregeneratehelptext",
|
||||
Placeholder: "theplaceholder",
|
||||
Options: []*PluginOption{
|
||||
&PluginOption{
|
||||
{
|
||||
DisplayName: "theoptiondisplayname",
|
||||
Value: "thevalue",
|
||||
},
|
||||
@@ -103,6 +105,8 @@ func TestManifestUnmarshal(t *testing.T) {
|
||||
var yamlResult Manifest
|
||||
require.NoError(t, yaml.Unmarshal([]byte(`
|
||||
id: theid
|
||||
homepage_url: https://example.com
|
||||
support_url: https://example.com/support
|
||||
icon_path: assets/icon.svg
|
||||
min_server_version: 5.6.0
|
||||
server:
|
||||
@@ -133,6 +137,8 @@ settings_schema:
|
||||
var jsonResult Manifest
|
||||
require.NoError(t, json.Unmarshal([]byte(`{
|
||||
"id": "theid",
|
||||
"homepage_url": "https://example.com",
|
||||
"support_url": "https://example.com/support",
|
||||
"icon_path": "assets/icon.svg",
|
||||
"min_server_version": "5.6.0",
|
||||
"server": {
|
||||
@@ -226,7 +232,7 @@ func TestManifestJson(t *testing.T) {
|
||||
Header: "theheadertext",
|
||||
Footer: "thefootertext",
|
||||
Settings: []*PluginSetting{
|
||||
&PluginSetting{
|
||||
{
|
||||
Key: "thesetting",
|
||||
DisplayName: "thedisplayname",
|
||||
Type: "dropdown",
|
||||
@@ -234,7 +240,7 @@ func TestManifestJson(t *testing.T) {
|
||||
RegenerateHelpText: "theregeneratehelptext",
|
||||
Placeholder: "theplaceholder",
|
||||
Options: []*PluginOption{
|
||||
&PluginOption{
|
||||
{
|
||||
DisplayName: "theoptiondisplayname",
|
||||
Value: "thevalue",
|
||||
},
|
||||
@@ -293,7 +299,7 @@ func TestManifestClientManifest(t *testing.T) {
|
||||
Header: "theheadertext",
|
||||
Footer: "thefootertext",
|
||||
Settings: []*PluginSetting{
|
||||
&PluginSetting{
|
||||
{
|
||||
Key: "thesetting",
|
||||
DisplayName: "thedisplayname",
|
||||
Type: "dropdown",
|
||||
@@ -301,7 +307,7 @@ func TestManifestClientManifest(t *testing.T) {
|
||||
RegenerateHelpText: "theregeneratehelptext",
|
||||
Placeholder: "theplaceholder",
|
||||
Options: []*PluginOption{
|
||||
&PluginOption{
|
||||
{
|
||||
DisplayName: "theoptiondisplayname",
|
||||
Value: "thevalue",
|
||||
},
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestSessionDeepCopy(t *testing.T) {
|
||||
@@ -17,7 +18,7 @@ func TestSessionDeepCopy(t *testing.T) {
|
||||
mapKey := "key"
|
||||
mapValue := "val"
|
||||
|
||||
session := &Session{Id: sessionId, Props: map[string]string{mapKey: mapValue}, TeamMembers: []*TeamMember{&TeamMember{UserId: userId, TeamId: "someteamId"}}}
|
||||
session := &Session{Id: sessionId, Props: map[string]string{mapKey: mapValue}, TeamMembers: []*TeamMember{{UserId: userId, TeamId: "someteamId"}}}
|
||||
|
||||
copySession := session.DeepCopy()
|
||||
copySession.Id = "changed"
|
||||
@@ -45,21 +46,16 @@ func TestSessionJson(t *testing.T) {
|
||||
json := session.ToJson()
|
||||
rsession := SessionFromJson(strings.NewReader(json))
|
||||
|
||||
if rsession.Id != session.Id {
|
||||
t.Fatal("Ids do not match")
|
||||
}
|
||||
require.Equal(t, rsession.Id, session.Id, "Ids do not match")
|
||||
|
||||
session.Sanitize()
|
||||
|
||||
if session.IsExpired() {
|
||||
t.Fatal("Shouldn't expire")
|
||||
}
|
||||
require.False(t, session.IsExpired(), "Shouldn't expire")
|
||||
|
||||
session.ExpiresAt = GetMillis()
|
||||
time.Sleep(10 * time.Millisecond)
|
||||
if !session.IsExpired() {
|
||||
t.Fatal("Should expire")
|
||||
}
|
||||
|
||||
require.True(t, session.IsExpired(), "Should expire")
|
||||
|
||||
session.SetExpireInDays(10)
|
||||
}
|
||||
|
||||
@@ -111,11 +111,7 @@ func (s *SlackAttachment) Equals(input *SlackAttachment) bool {
|
||||
}
|
||||
}
|
||||
|
||||
if s.Timestamp != input.Timestamp {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
return s.Timestamp == input.Timestamp
|
||||
}
|
||||
|
||||
type SlackAttachmentField struct {
|
||||
|
||||
@@ -63,7 +63,7 @@ func TestUserPreSave(t *testing.T) {
|
||||
user.PreSave()
|
||||
user.Etag(true, true)
|
||||
assert.NotNil(t, user.Timezone, "Timezone is nil")
|
||||
assert.Equal(t, user.Timezone["useAutomaticTimezone"], "true", "Timezone is not set to default");
|
||||
assert.Equal(t, user.Timezone["useAutomaticTimezone"], "true", "Timezone is not set to default")
|
||||
}
|
||||
|
||||
func TestUserPreUpdate(t *testing.T) {
|
||||
|
||||
Ссылка в новой задаче
Block a user