mirror of
https://github.com/hanzoai/team.git
synced 2026-09-30 01:57:35 +00:00
* MM-67976: Add server uptime to support packet Add process start time (started_at) and approximate host start time (host_started_at, Linux only, derived from /proc/uptime) to the support packet diagnostics. This helps diagnose restart loops and distinguish process restarts from full machine/container reboots. * Add HostStartedAt assertions to support packet happy-path test * Revert unrelated changes * Add unit tests for getHostUptimeSeconds and fix cross-platform portability - Extract parseUptimeFile helper in uptime_linux.go to enable unit testing with synthetic file paths without touching the real /proc/uptime - Add uptime_linux_test.go covering all error paths (file read error, empty file, non-numeric value) and happy-path parsing - Add uptime_other_test.go asserting the non-Linux stub returns ErrHostUptimeUnsupportedPlatform and zero seconds - Guard HostStartedAt assertions in support_packet_test.go with runtime.GOOS so the test correctly asserts zero-time on non-Linux platforms instead of failing * test: use t.TempDir() for guaranteed-missing path in uptime test Replace the hard-coded /nonexistent/proc/uptime path with a path constructed from t.TempDir() to guarantee the file is absent without relying on filesystem layout assumptions. Also remove the misleading comment about swapping implementations. * Reorder Server struct fields and assignments to group process identity fields together * Add macOS support for host uptime in support packet --------- Co-authored-by: Hanzo Dev <[email protected]>
21 lines
467 B
Go
21 lines
467 B
Go
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
//go:build !linux && !darwin
|
|
|
|
package platform
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestGetHostUptimeSeconds(t *testing.T) {
|
|
seconds, err := getHostUptimeSeconds()
|
|
require.Error(t, err)
|
|
assert.ErrorIs(t, err, ErrHostUptimeUnsupportedPlatform)
|
|
assert.Equal(t, int64(0), seconds)
|
|
}
|