Full Mattermost server source with integrated Community Enterprise features. Includes vendor directory for offline/air-gapped builds. Structure: - enterprise-impl/: Enterprise feature implementations - enterprise-community/: Init files that register implementations - enterprise/: Bridge imports (community_imports.go) - vendor/: All dependencies for offline builds Build (online): go build ./cmd/mattermost Build (offline/air-gapped): go build -mod=vendor ./cmd/mattermost 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
78 lines
1.8 KiB
Go
78 lines
1.8 KiB
Go
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
package model
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestPerformanceReport_IsValid(t *testing.T) {
|
|
outdatedTimestamp := time.Now().Add(-6 * time.Minute).UnixMilli()
|
|
tests := []struct {
|
|
name string
|
|
report *PerformanceReport
|
|
expected string
|
|
}{
|
|
{
|
|
name: "ValidReport",
|
|
report: &PerformanceReport{
|
|
Version: "0.1.0",
|
|
Labels: map[string]string{"platform": "linux"},
|
|
Start: float64(time.Now().UnixMilli() - 10000),
|
|
End: float64(time.Now().UnixMilli()),
|
|
},
|
|
expected: "",
|
|
},
|
|
{
|
|
name: "NilReport",
|
|
report: nil,
|
|
expected: "the report is nil",
|
|
},
|
|
{
|
|
name: "UnsupportedVersion",
|
|
report: &PerformanceReport{
|
|
Version: "2.0.0",
|
|
Labels: map[string]string{"platform": "linux"},
|
|
Start: float64(time.Now().UnixMilli() - 10000),
|
|
End: float64(time.Now().UnixMilli()),
|
|
},
|
|
expected: "report version is not supported:",
|
|
},
|
|
{
|
|
name: "ErroneousTimestamps",
|
|
report: &PerformanceReport{
|
|
Version: "0.1.0",
|
|
Labels: map[string]string{"platform": "linux"},
|
|
Start: float64(time.Now().UnixMilli()),
|
|
End: float64(time.Now().Add(-1 * time.Hour).UnixMilli()),
|
|
},
|
|
expected: "report timestamps are erroneous",
|
|
},
|
|
{
|
|
name: "OutdatedReport",
|
|
report: &PerformanceReport{
|
|
Version: "0.1.0",
|
|
Labels: map[string]string{"platform": "linux"},
|
|
Start: float64(time.Now().Add(-7 * time.Minute).UnixMilli()),
|
|
End: float64(outdatedTimestamp),
|
|
},
|
|
expected: "report is outdated:",
|
|
},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
err := tt.report.IsValid()
|
|
if tt.expected != "" {
|
|
require.Contains(t, err.Error(), tt.expected)
|
|
return
|
|
}
|
|
require.NoError(t, err)
|
|
})
|
|
}
|
|
}
|