MCPcopy Create free account
hub / github.com/containerd/nerdctl / TestTimeSinceInHuman

Function TestTimeSinceInHuman

pkg/formatter/formatter_test.go:29–92  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

27)
28
29func TestTimeSinceInHuman(t *testing.T) {
30 now := time.Now()
31 t.Parallel()
32
33 tests := []struct {
34 name string
35 input time.Time
36 expected string
37 }{
38 {
39 name: "1 second ago",
40 input: now.Add(-1 * time.Second),
41 expected: "1 second ago",
42 },
43 {
44 name: "59 seconds ago",
45 input: now.Add(-59 * time.Second),
46 expected: "59 seconds ago",
47 },
48 {
49 name: "1 minute ago",
50 input: now.Add(-1 * time.Minute),
51 expected: "About a minute ago",
52 },
53 {
54 name: "1 hour ago",
55 input: now.Add(-1 * time.Hour),
56 expected: "About an hour ago",
57 },
58 {
59 name: "1 day ago",
60 input: now.Add(-24 * time.Hour),
61 expected: "24 hours ago",
62 },
63 {
64 name: "4 days ago",
65 input: now.Add(-4 * 24 * time.Hour),
66 expected: "4 days ago",
67 },
68 {
69 name: "1 year ago",
70 input: now.Add(-365 * 24 * time.Hour),
71 expected: "12 months ago",
72 },
73 {
74 name: "4 years ago",
75 input: now.Add(-4 * 365 * 24 * time.Hour),
76 expected: "4 years ago",
77 },
78 {
79 name: "zero duration",
80 input: now,
81 expected: "Less than a second ago",
82 },
83 }
84
85 for _, tt := range tests {
86 t.Run(tt.name, func(t *testing.T) {

Callers

nothing calls this directly

Calls 3

TimeSinceInHumanFunction · 0.85
AddMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…