MCPcopy Create free account
hub / github.com/cli/cli / TestFuzzyAgoAbbr

Function TestFuzzyAgoAbbr

internal/text/text_test.go:37–58  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

35}
36
37func TestFuzzyAgoAbbr(t *testing.T) {
38 const form = "2006-Jan-02 15:04:05"
39 now, _ := time.Parse(form, "2020-Nov-22 14:00:00")
40 cases := map[string]string{
41 "2020-Nov-22 14:00:00": "0m",
42 "2020-Nov-22 13:59:00": "1m",
43 "2020-Nov-22 13:30:00": "30m",
44 "2020-Nov-22 13:00:00": "1h",
45 "2020-Nov-22 02:00:00": "12h",
46 "2020-Nov-21 14:00:00": "1d",
47 "2020-Nov-07 14:00:00": "15d",
48 "2020-Oct-24 14:00:00": "29d",
49 "2020-Oct-23 14:00:00": "Oct 23, 2020",
50 "2019-Nov-22 14:00:00": "Nov 22, 2019",
51 }
52 for createdAt, expected := range cases {
53 d, err := time.Parse(form, createdAt)
54 assert.NoError(t, err)
55 fuzzy := FuzzyAgoAbbr(now, d)
56 assert.Equal(t, expected, fuzzy)
57 }
58}
59
60func TestFuzzyIn(t *testing.T) {
61 const form = "2006-Jan-02 15:04:05"

Callers

nothing calls this directly

Calls 2

FuzzyAgoAbbrFunction · 0.85
EqualMethod · 0.80

Tested by

no test coverage detected