MCPcopy Index your code
hub / github.com/cli/cli / TestPreciseAgo

Function TestPreciseAgo

pkg/cmd/run/shared/shared_test.go:19–42  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

17)
18
19func TestPreciseAgo(t *testing.T) {
20 const form = "2006-Jan-02 15:04:05"
21 now, _ := time.Parse(form, "2021-Apr-12 14:00:00")
22
23 cases := map[string]string{
24 "2021-Apr-12 14:00:00": "0s ago",
25 "2021-Apr-12 13:59:30": "30s ago",
26 "2021-Apr-12 13:59:00": "1m0s ago",
27 "2021-Apr-12 13:30:15": "29m45s ago",
28 "2021-Apr-12 13:00:00": "1h0m0s ago",
29 "2021-Apr-12 02:30:45": "11h29m15s ago",
30 "2021-Apr-11 14:00:00": "24h0m0s ago",
31 "2021-Apr-01 14:00:00": "264h0m0s ago",
32 "2021-Mar-12 14:00:00": "Mar 12, 2021",
33 }
34
35 for createdAt, expected := range cases {
36 d, _ := time.Parse(form, createdAt)
37 got := preciseAgo(now, d)
38 if got != expected {
39 t.Errorf("expected %s but got %s for %s", expected, got, createdAt)
40 }
41 }
42}
43
44func TestGetAnnotations404(t *testing.T) {
45 reg := &httpmock.Registry{}

Callers

nothing calls this directly

Calls 2

preciseAgoFunction · 0.85
ErrorfMethod · 0.65

Tested by

no test coverage detected