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

Function TestFuzzyAgoAbbr

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 2

FuzzyAgoAbbrFunction · 0.85
EqualMethod · 0.80

Tested by

no test coverage detected