Skip to content

issue view tests fails after 2021-01-23 #2841

@cristiand391

Description

@cristiand391

Describe the bug

The current implementation of issue view tests doesn't mock the current time and makes test fail after 2021-01-23.

Steps to reproduce the behavior

  1. Clone cli/cli
  2. Type go test ./pkg/cmd/issue/view
  3. See
FAIL: TestIssueView_tty_Preview (0.00s)
    --- FAIL: TestIssueView_tty_Preview/Open_issue_with_empty_body (0.00s)
        view_test.go:267: output did not match regexp /Open.*marseilles opened about 9 years ago.*9 comments/
            > output
            ix of coins
            Open • marseilles opened about 10 years ago • 9 comments
            Labels: tarot

These tests started to fail 2 days ago because the dates in the test fixtures point to 2011-01-26

"createdAt": "2011-01-26T19:01:12Z",
, which makes
func printHumanIssuePreview(opts *ViewOptions, issue *api.Issue) error {
out := opts.IO.Out
now := time.Now()
ago := now.Sub(issue.CreatedAt)

output:
Open • marseilles opened about 10 years ago • 9 comments
instead of:
Open • marseilles opened about 9 years ago • 9 comments.

See: https://github.com/cli/cli/pull/2839/checks?check_run_id=1758707814#step:5:55

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions