-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils_test.go
More file actions
50 lines (43 loc) · 1.15 KB
/
utils_test.go
File metadata and controls
50 lines (43 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package main
import (
"testing"
"time"
"github.com/stretchr/testify/assert"
)
func TestFormatDurationAsMMSS(t *testing.T) {
tests := []struct {
duration int64
expected string
}{
{0, "00:00"},
{59, "00:59"},
{60, "01:00"},
{61, "01:01"},
{3600, "60:00"},
}
for _, test := range tests {
result := formatDurationAsMMSS(test.duration)
assert.Equal(t, test.expected, result, "formatDurationAsMMSS(%d)", test.duration)
}
}
func TestDateFormatInTable(t *testing.T) {
// Test that dates are formatted correctly in the table view
testCases := []struct {
input string
expected string
}{
{"2026-01-07 10:30:45", "Wednesday, 7 Jan 26"},
{"2026-01-01 00:00:00", "Thursday, 1 Jan 26"},
{"2025-12-25 15:30:00", "Thursday, 25 Dec 25"},
}
for _, tc := range testCases {
t.Run(tc.input, func(t *testing.T) {
// Parse the datetime string
parsedTime, err := time.Parse("2006-01-02 15:04:05", tc.input)
assert.NoError(t, err)
// Format it the way the table should display it
formatted := parsedTime.Format("Monday, 2 Jan 06")
assert.Equal(t, tc.expected, formatted, "Date should be formatted as '%s'", tc.expected)
})
}
}