Этот коммит содержится в:
Ben Schumacher
2023-10-11 10:13:36 +02:00
коммит произвёл GitHub
родитель 176370e175
Коммит 0d5a8b8841
189 изменённых файлов: 1 добавлений и 361 удалений

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

@@ -59,7 +59,6 @@ func (ad *AccessData) IsValid() *AppError {
}
func (ad *AccessData) IsExpired() bool {
if ad.ExpiresAt <= 0 {
return false
}

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

@@ -36,7 +36,6 @@ type AuthorizeRequest struct {
// IsValid validates the AuthData and returns an error if it isn't configured
// correctly.
func (ad *AuthData) IsValid() *AppError {
if !IsValidId(ad.ClientId) {
return NewAppError("AuthData.IsValid", "model.authorize.is_valid.client_id.app_error", nil, "", http.StatusBadRequest)
}
@@ -75,7 +74,6 @@ func (ad *AuthData) IsValid() *AppError {
// IsValid validates the AuthorizeRequest and returns an error if it isn't configured
// correctly.
func (ar *AuthorizeRequest) IsValid() *AppError {
if !IsValidId(ar.ClientId) {
return NewAppError("AuthData.IsValid", "model.authorize.is_valid.client_id.app_error", nil, "", http.StatusBadRequest)
}

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

@@ -19,7 +19,6 @@ func TestAuthPreSave(t *testing.T) {
}
func TestAuthIsValid(t *testing.T) {
ad := AuthData{}
require.NotNil(t, ad.IsValid())

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

@@ -205,7 +205,6 @@ func (l *BotList) Etag() string {
t = v.UpdateAt
id = v.UserId
}
}
return Etag(id, t, delta, len(*l))

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

@@ -6,7 +6,6 @@ package model
type ChannelList []*Channel
func (o *ChannelList) Etag() string {
id := "0"
var t int64
var delta int64
@@ -21,7 +20,6 @@ func (o *ChannelList) Etag() string {
t = v.UpdateAt
id = v.Id
}
}
return Etag(id, t, delta, len(*o))
@@ -30,7 +28,6 @@ func (o *ChannelList) Etag() string {
type ChannelListWithTeamData []*ChannelWithTeamData
func (o *ChannelListWithTeamData) Etag() string {
id := "0"
var t int64
var delta int64

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

@@ -126,7 +126,6 @@ func TestClient4RequestCancellation(t *testing.T) {
})
t.Run("cancel after making the reqeust", func(t *testing.T) {
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
time.Sleep(100 * time.Millisecond)
t.Fatal("request should not hit the server")
@@ -144,7 +143,6 @@ func TestClient4RequestCancellation(t *testing.T) {
assert.Nil(t, resp)
done <- struct{}{}
}()
cancel()

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

@@ -213,7 +213,6 @@ func (ad *AutocompleteData) UpdateRelativeURLsForPluginCommands(baseURL *url.URL
absURL.Path = path.Join(absURL.Path, dynamicList.FetchURL)
dynamicList.FetchURL = absURL.String()
}
}
for _, command := range ad.SubCommands {
err := command.UpdateRelativeURLsForPluginCommands(baseURL)

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

@@ -76,7 +76,6 @@ func cleanComplianceStrings(in string) string {
}
func (cp *CompliancePost) Row() []string {
postDeleteAt := ""
if cp.PostDeleteAt > 0 {
postDeleteAt = time.Unix(0, cp.PostDeleteAt*int64(1000*1000)).Format(time.RFC3339)

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

@@ -2090,7 +2090,6 @@ func (s *AnnouncementSettings) SetDefaults() {
if s.NoticesFetchFrequency == nil {
s.NoticesFetchFrequency = NewInt(AnnouncementSettingsDefaultNoticesFetchFrequencySeconds)
}
}
type ThemeSettings struct {
@@ -2146,7 +2145,6 @@ type TeamSettings struct {
}
func (s *TeamSettings) SetDefaults() {
if s.SiteName == nil || *s.SiteName == "" {
s.SiteName = NewString(TeamSettingsDefaultSiteName)
}

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

@@ -50,7 +50,6 @@ func TestConfigDefaults(t *testing.T) {
if assert.False(t, v.IsNil(), "%s should be non-nil after SetDefaults()", name) {
recursivelyUninitialize(config, fmt.Sprintf("(*%s)", name), v.Elem())
}
} else if v.Type().Kind() == reflect.Struct {
for i := 0; i < v.NumField(); i++ {
recursivelyUninitialize(config, fmt.Sprintf("%s.%s", name, v.Type().Field(i).Name), v.Field(i))
@@ -728,7 +727,6 @@ func TestDisplaySettingsIsValidCustomURLSchemes(t *testing.T) {
}
func TestListenAddressIsValidated(t *testing.T) {
testValues := map[string]bool{
":8065": true,
":9917": true,
@@ -766,7 +764,6 @@ func TestListenAddressIsValidated(t *testing.T) {
require.Equal(t, "model.config.is_valid.listen_address.app_error", appErr.Message)
}
}
}
func TestImageProxySettingsSetDefaults(t *testing.T) {
@@ -1332,7 +1329,6 @@ func TestSetDefaultFeatureFlagBehaviour(t *testing.T) {
cfg.SetDefaults()
require.NotNil(t, cfg.FeatureFlags)
require.Equal(t, "somevalue", cfg.FeatureFlags.TestFeature)
}
func TestConfigImportSettingsDefaults(t *testing.T) {

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

@@ -243,7 +243,6 @@ func (group *Group) IsValidForUpdate() *AppError {
var validGroupnameChars = regexp.MustCompile(`^[a-z0-9\.\-_]+$`)
func (group *Group) IsValidName() *AppError {
if group.Name == nil {
if group.AllowReference {
return NewAppError("Group.IsValidName", "model.group.name.app_error", map[string]any{"GroupNameMaxLength": GroupNameMaxLength}, "", http.StatusBadRequest)

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

@@ -61,7 +61,6 @@ type IncomingWebhookRequest struct {
func (o *IncomingWebhook) IsValid() *AppError {
if !IsValidId(o.Id) {
return NewAppError("IncomingWebhook.IsValid", "model.incoming_hook.id.app_error", nil, "", http.StatusBadRequest)
}
if o.CreateAt == 0 {

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

@@ -227,7 +227,6 @@ func TestIsLegacyTrialRequest(t *testing.T) {
legacyTr.ContactName = ""
assert.True(t, legacyTr.IsLegacy())
})
}
func TestTrialLicenseRequestIsValid(t *testing.T) {
@@ -439,7 +438,6 @@ func TestLicense_IsSanctionedTrial(t *testing.T) {
}
func TestLicenseHasSharedChannels(t *testing.T) {
testCases := []struct {
description string
license License

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

@@ -293,7 +293,6 @@ func TestFirstNImages(t *testing.T) {
}
assert.Len(t, firstNImages(six, -10), LinkMetadataMaxImages, "On negative, go for defaults")
})
}
func TestTruncateOpenGraph(t *testing.T) {

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

@@ -51,7 +51,6 @@ func (a *OAuthApp) Auditable() map[string]interface{} {
// IsValid validates the app and returns an error if it isn't configured
// correctly.
func (a *OAuthApp) IsValid() *AppError {
if !IsValidId(a.Id) {
return NewAppError("OAuthApp.IsValid", "model.oauth.is_valid.app_id.app_error", nil, "", http.StatusBadRequest)
}

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

@@ -96,7 +96,6 @@ func (o *OutgoingWebhookPayload) ToFormValues() string {
}
func (o *OutgoingWebhook) IsValid() *AppError {
if !IsValidId(o.Id) {
return NewAppError("OutgoingWebhook.IsValid", "model.outgoing_hook.is_valid.id.app_error", nil, "", http.StatusBadRequest)
}

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

@@ -113,7 +113,6 @@ func (o *PostList) MakeNonNil() {
}
func (o *PostList) AddOrder(id string) {
if o.Order == nil {
o.Order = make([]string, 0, 128)
}
@@ -122,7 +121,6 @@ func (o *PostList) AddOrder(id string) {
}
func (o *PostList) AddPost(post *Post) {
if o.Posts == nil {
o.Posts = make(map[string]*Post)
}
@@ -162,7 +160,6 @@ func (o *PostList) SortByCreateAt() {
}
func (o *PostList) Etag() string {
id := "0"
var t int64

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

@@ -971,5 +971,4 @@ func TestPostForPlugin(t *testing.T) {
pluginPost := p.ForPlugin()
require.NotNil(t, pluginPost.GetProp("requested_features"))
})
}

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

@@ -10,7 +10,6 @@ import (
)
func TestPushNotificationDeviceId(t *testing.T) {
msg := PushNotification{Platform: "test"}
msg.SetDeviceIdAndPlatform("android:12345")

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

@@ -113,7 +113,6 @@ func TestSplitWords(t *testing.T) {
assert.Equal(t, testCase.Output, splitWords(testCase.Input))
})
}
}
func TestParseSearchFlags2(t *testing.T) {

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

@@ -140,7 +140,6 @@ func (s *Session) Sanitize() {
}
func (s *Session) IsExpired() bool {
if s.ExpiresAt <= 0 {
return false
}
@@ -153,7 +152,6 @@ func (s *Session) IsExpired() bool {
}
func (s *Session) AddProp(key string, value string) {
if s.Props == nil {
s.Props = make(map[string]string)
}

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

@@ -796,7 +796,6 @@ func (u *User) GetRawRoles() string {
}
func IsValidUserRoles(userRoles string) bool {
roles := strings.Fields(userRoles)
for _, r := range roles {

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

@@ -82,13 +82,11 @@ func (sa StringArray) Contains(input string) bool {
return false
}
func (sa StringArray) Equals(input StringArray) bool {
if len(sa) != len(input) {
return false
}
for index := range sa {
if sa[index] != input[index] {
return false
}
@@ -586,7 +584,6 @@ func GetServerIPAddress(iface string) string {
}
for _, addr := range addrs {
if ip, ok := addr.(*net.IPNet); ok && !ip.IP.IsLoopback() && !ip.IP.IsLinkLocalUnicast() && !ip.IP.IsLinkLocalMulticast() {
if ip.IP.To4() != nil {
return ip.IP.String()
@@ -664,7 +661,6 @@ func IsValidAlphaNumHyphenUnderscorePlus(s string) bool {
}
func Etag(parts ...any) string {
etag := CurrentVersion
for _, part := range parts {

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

@@ -183,7 +183,6 @@ func TestCopyStringMap(t *testing.T) {
}
func TestMapJson(t *testing.T) {
m := make(map[string]string)
m["id"] = "test_id"
json := MapToJSON(m)

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

@@ -65,7 +65,6 @@ func FindMethodsCalledOnType(info *types.Info, typ types.Type, caller *ast.FuncD
ast.Inspect(caller, func(n ast.Node) bool {
if s, ok := n.(*ast.SelectorExpr); ok {
var receiver *ast.Ident
switch r := s.X.(type) {
case *ast.Ident:
@@ -90,7 +89,6 @@ func FindMethodsCalledOnType(info *types.Info, typ types.Type, caller *ast.FuncD
}
return false
}
}
return true
})

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

@@ -652,7 +652,6 @@ func (s *hooksRPCServer) MessageWillBePosted(args *Z_MessageWillBePostedArgs, re
MessageWillBePosted(c *Context, post *model.Post) (*model.Post, string)
}); ok {
returns.A, returns.B = hook.MessageWillBePosted(args.A, args.B)
} else {
return encodableError(fmt.Errorf("hook MessageWillBePosted called but not implemented"))
}
@@ -693,7 +692,6 @@ func (s *hooksRPCServer) MessageWillBeUpdated(args *Z_MessageWillBeUpdatedArgs,
MessageWillBeUpdated(c *Context, newPost, oldPost *model.Post) (*model.Post, string)
}); ok {
returns.A, returns.B = hook.MessageWillBeUpdated(args.A, args.B, args.C)
} else {
return encodableError(fmt.Errorf("hook MessageWillBeUpdated called but not implemented"))
}
@@ -715,7 +713,6 @@ func (g *apiRPCClient) LogDebug(msg string, keyValuePairs ...any) {
if err := g.client.Call("Plugin.LogDebug", _args, _returns); err != nil {
log.Printf("RPC call to LogDebug API failed: %s", err.Error())
}
}
func (s *apiRPCServer) LogDebug(args *Z_LogDebugArgs, returns *Z_LogDebugReturns) error {
@@ -744,7 +741,6 @@ func (g *apiRPCClient) LogInfo(msg string, keyValuePairs ...any) {
if err := g.client.Call("Plugin.LogInfo", _args, _returns); err != nil {
log.Printf("RPC call to LogInfo API failed: %s", err.Error())
}
}
func (s *apiRPCServer) LogInfo(args *Z_LogInfoArgs, returns *Z_LogInfoReturns) error {
@@ -773,7 +769,6 @@ func (g *apiRPCClient) LogWarn(msg string, keyValuePairs ...any) {
if err := g.client.Call("Plugin.LogWarn", _args, _returns); err != nil {
log.Printf("RPC call to LogWarn API failed: %s", err.Error())
}
}
func (s *apiRPCServer) LogWarn(args *Z_LogWarnArgs, returns *Z_LogWarnReturns) error {

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

@@ -128,7 +128,6 @@ func FieldListToEncodedErrors(structPrefix string, fieldList *ast.FieldList, fil
}
result = append(result, structPrefix+name+" = encodableError("+structPrefix+name+")")
}
return strings.Join(result, "\n")

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

@@ -108,8 +108,6 @@ func TestTextRanges(t *testing.T) {
})
assert.Equal(t, tc.ExpectedRanges, ranges)
assert.Equal(t, tc.ExpectedValues, values)
})
}
}

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

@@ -29,5 +29,4 @@ func TestDefaultUserTimezone(t *testing.T) {
require.Equal(t, "true", defaultTimezone2["useAutomaticTimezone"])
require.Empty(t, defaultTimezone2["automaticTimezone"])
require.Empty(t, defaultTimezone2["manualTimezone"])
}