Merge pull request #8454 from cli/wm/fix-time-flake-tests

Fix flaky tests coupled to relative dates
This commit is contained in:
William Martin 2023-12-13 15:00:04 +01:00 committed by GitHub
commit 6d11395c08
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 117 additions and 117 deletions

View file

@ -120,8 +120,8 @@ func listRun(opts *ListOptions) error {
tp.AddField(opts.IO.ColorScheme().Cyan(fmt.Sprintf("%d", cache.Id)))
tp.AddField(cache.Key)
tp.AddField(humanFileSize(cache.SizeInBytes))
tp.AddTimeField(time.Now(), cache.CreatedAt, opts.IO.ColorScheme().Gray)
tp.AddTimeField(time.Now(), cache.LastAccessedAt, opts.IO.ColorScheme().Gray)
tp.AddTimeField(opts.Now, cache.CreatedAt, opts.IO.ColorScheme().Gray)
tp.AddTimeField(opts.Now, cache.LastAccessedAt, opts.IO.ColorScheme().Gray)
tp.EndRow()
}

View file

@ -158,7 +158,7 @@ func listRun(opts *ListOptions) error {
tp.AddField(string(run.Event))
tp.AddField(fmt.Sprintf("%d", run.ID), tableprinter.WithColor(cs.Cyan))
tp.AddField(run.Duration(opts.now).String())
tp.AddTimeField(time.Now(), run.StartedTime(), cs.Gray)
tp.AddTimeField(opts.now, run.StartedTime(), cs.Gray)
tp.EndRow()
}

View file

@ -169,16 +169,16 @@ func TestListRun(t *testing.T) {
},
wantOut: heredoc.Doc(`
STATUS TITLE WORKFLOW BRANCH EVENT ID ELAPSED AGE
X cool commit CI trunk push 1 4m34s about 2 years ago
* cool commit CI trunk push 2 4m34s about 2 years ago
cool commit CI trunk push 3 4m34s about 2 years ago
X cool commit CI trunk push 4 4m34s about 2 years ago
X cool commit CI trunk push 1234 4m34s about 2 years ago
- cool commit CI trunk push 6 4m34s about 2 years ago
- cool commit CI trunk push 7 4m34s about 2 years ago
* cool commit CI trunk push 8 4m34s about 2 years ago
* cool commit CI trunk push 9 4m34s about 2 years ago
X cool commit CI trunk push 10 4m34s about 2 years ago
X cool commit CI trunk push 1 4m34s about 4 minutes ago
* cool commit CI trunk push 2 4m34s about 4 minutes ago
cool commit CI trunk push 3 4m34s about 4 minutes ago
X cool commit CI trunk push 4 4m34s about 4 minutes ago
X cool commit CI trunk push 1234 4m34s about 4 minutes ago
- cool commit CI trunk push 6 4m34s about 4 minutes ago
- cool commit CI trunk push 7 4m34s about 4 minutes ago
* cool commit CI trunk push 8 4m34s about 4 minutes ago
* cool commit CI trunk push 9 4m34s about 4 minutes ago
X cool commit CI trunk push 10 4m34s about 4 minutes ago
`),
},
{
@ -249,107 +249,107 @@ func TestListRun(t *testing.T) {
},
wantOut: heredoc.Doc(`
STATUS TITLE WORKFLOW BRANCH EVENT ID ELAPSED AGE
* cool commit CI trunk push 0 4m34s about 2 years ago
* cool commit CI trunk push 1 4m34s about 2 years ago
* cool commit CI trunk push 2 4m34s about 2 years ago
* cool commit CI trunk push 3 4m34s about 2 years ago
* cool commit CI trunk push 4 4m34s about 2 years ago
* cool commit CI trunk push 5 4m34s about 2 years ago
* cool commit CI trunk push 6 4m34s about 2 years ago
* cool commit CI trunk push 7 4m34s about 2 years ago
* cool commit CI trunk push 8 4m34s about 2 years ago
* cool commit CI trunk push 9 4m34s about 2 years ago
* cool commit CI trunk push 10 4m34s about 2 years ago
* cool commit CI trunk push 11 4m34s about 2 years ago
* cool commit CI trunk push 12 4m34s about 2 years ago
* cool commit CI trunk push 13 4m34s about 2 years ago
* cool commit CI trunk push 14 4m34s about 2 years ago
* cool commit CI trunk push 15 4m34s about 2 years ago
* cool commit CI trunk push 16 4m34s about 2 years ago
* cool commit CI trunk push 17 4m34s about 2 years ago
* cool commit CI trunk push 18 4m34s about 2 years ago
* cool commit CI trunk push 19 4m34s about 2 years ago
* cool commit CI trunk push 20 4m34s about 2 years ago
* cool commit CI trunk push 21 4m34s about 2 years ago
* cool commit CI trunk push 22 4m34s about 2 years ago
* cool commit CI trunk push 23 4m34s about 2 years ago
* cool commit CI trunk push 24 4m34s about 2 years ago
* cool commit CI trunk push 25 4m34s about 2 years ago
* cool commit CI trunk push 26 4m34s about 2 years ago
* cool commit CI trunk push 27 4m34s about 2 years ago
* cool commit CI trunk push 28 4m34s about 2 years ago
* cool commit CI trunk push 29 4m34s about 2 years ago
* cool commit CI trunk push 30 4m34s about 2 years ago
* cool commit CI trunk push 31 4m34s about 2 years ago
* cool commit CI trunk push 32 4m34s about 2 years ago
* cool commit CI trunk push 33 4m34s about 2 years ago
* cool commit CI trunk push 34 4m34s about 2 years ago
* cool commit CI trunk push 35 4m34s about 2 years ago
* cool commit CI trunk push 36 4m34s about 2 years ago
* cool commit CI trunk push 37 4m34s about 2 years ago
* cool commit CI trunk push 38 4m34s about 2 years ago
* cool commit CI trunk push 39 4m34s about 2 years ago
* cool commit CI trunk push 40 4m34s about 2 years ago
* cool commit CI trunk push 41 4m34s about 2 years ago
* cool commit CI trunk push 42 4m34s about 2 years ago
* cool commit CI trunk push 43 4m34s about 2 years ago
* cool commit CI trunk push 44 4m34s about 2 years ago
* cool commit CI trunk push 45 4m34s about 2 years ago
* cool commit CI trunk push 46 4m34s about 2 years ago
* cool commit CI trunk push 47 4m34s about 2 years ago
* cool commit CI trunk push 48 4m34s about 2 years ago
* cool commit CI trunk push 49 4m34s about 2 years ago
* cool commit CI trunk push 50 4m34s about 2 years ago
* cool commit CI trunk push 51 4m34s about 2 years ago
* cool commit CI trunk push 52 4m34s about 2 years ago
* cool commit CI trunk push 53 4m34s about 2 years ago
* cool commit CI trunk push 54 4m34s about 2 years ago
* cool commit CI trunk push 55 4m34s about 2 years ago
* cool commit CI trunk push 56 4m34s about 2 years ago
* cool commit CI trunk push 57 4m34s about 2 years ago
* cool commit CI trunk push 58 4m34s about 2 years ago
* cool commit CI trunk push 59 4m34s about 2 years ago
* cool commit CI trunk push 60 4m34s about 2 years ago
* cool commit CI trunk push 61 4m34s about 2 years ago
* cool commit CI trunk push 62 4m34s about 2 years ago
* cool commit CI trunk push 63 4m34s about 2 years ago
* cool commit CI trunk push 64 4m34s about 2 years ago
* cool commit CI trunk push 65 4m34s about 2 years ago
* cool commit CI trunk push 66 4m34s about 2 years ago
* cool commit CI trunk push 67 4m34s about 2 years ago
* cool commit CI trunk push 68 4m34s about 2 years ago
* cool commit CI trunk push 69 4m34s about 2 years ago
* cool commit CI trunk push 70 4m34s about 2 years ago
* cool commit CI trunk push 71 4m34s about 2 years ago
* cool commit CI trunk push 72 4m34s about 2 years ago
* cool commit CI trunk push 73 4m34s about 2 years ago
* cool commit CI trunk push 74 4m34s about 2 years ago
* cool commit CI trunk push 75 4m34s about 2 years ago
* cool commit CI trunk push 76 4m34s about 2 years ago
* cool commit CI trunk push 77 4m34s about 2 years ago
* cool commit CI trunk push 78 4m34s about 2 years ago
* cool commit CI trunk push 79 4m34s about 2 years ago
* cool commit CI trunk push 80 4m34s about 2 years ago
* cool commit CI trunk push 81 4m34s about 2 years ago
* cool commit CI trunk push 82 4m34s about 2 years ago
* cool commit CI trunk push 83 4m34s about 2 years ago
* cool commit CI trunk push 84 4m34s about 2 years ago
* cool commit CI trunk push 85 4m34s about 2 years ago
* cool commit CI trunk push 86 4m34s about 2 years ago
* cool commit CI trunk push 87 4m34s about 2 years ago
* cool commit CI trunk push 88 4m34s about 2 years ago
* cool commit CI trunk push 89 4m34s about 2 years ago
* cool commit CI trunk push 90 4m34s about 2 years ago
* cool commit CI trunk push 91 4m34s about 2 years ago
* cool commit CI trunk push 92 4m34s about 2 years ago
* cool commit CI trunk push 93 4m34s about 2 years ago
* cool commit CI trunk push 94 4m34s about 2 years ago
* cool commit CI trunk push 95 4m34s about 2 years ago
* cool commit CI trunk push 96 4m34s about 2 years ago
* cool commit CI trunk push 97 4m34s about 2 years ago
* cool commit CI trunk push 98 4m34s about 2 years ago
* cool commit CI trunk push 99 4m34s about 2 years ago
* cool commit CI trunk push 100 4m34s about 2 years ago
* cool commit CI trunk push 0 4m34s about 4 minutes ago
* cool commit CI trunk push 1 4m34s about 4 minutes ago
* cool commit CI trunk push 2 4m34s about 4 minutes ago
* cool commit CI trunk push 3 4m34s about 4 minutes ago
* cool commit CI trunk push 4 4m34s about 4 minutes ago
* cool commit CI trunk push 5 4m34s about 4 minutes ago
* cool commit CI trunk push 6 4m34s about 4 minutes ago
* cool commit CI trunk push 7 4m34s about 4 minutes ago
* cool commit CI trunk push 8 4m34s about 4 minutes ago
* cool commit CI trunk push 9 4m34s about 4 minutes ago
* cool commit CI trunk push 10 4m34s about 4 minutes ago
* cool commit CI trunk push 11 4m34s about 4 minutes ago
* cool commit CI trunk push 12 4m34s about 4 minutes ago
* cool commit CI trunk push 13 4m34s about 4 minutes ago
* cool commit CI trunk push 14 4m34s about 4 minutes ago
* cool commit CI trunk push 15 4m34s about 4 minutes ago
* cool commit CI trunk push 16 4m34s about 4 minutes ago
* cool commit CI trunk push 17 4m34s about 4 minutes ago
* cool commit CI trunk push 18 4m34s about 4 minutes ago
* cool commit CI trunk push 19 4m34s about 4 minutes ago
* cool commit CI trunk push 20 4m34s about 4 minutes ago
* cool commit CI trunk push 21 4m34s about 4 minutes ago
* cool commit CI trunk push 22 4m34s about 4 minutes ago
* cool commit CI trunk push 23 4m34s about 4 minutes ago
* cool commit CI trunk push 24 4m34s about 4 minutes ago
* cool commit CI trunk push 25 4m34s about 4 minutes ago
* cool commit CI trunk push 26 4m34s about 4 minutes ago
* cool commit CI trunk push 27 4m34s about 4 minutes ago
* cool commit CI trunk push 28 4m34s about 4 minutes ago
* cool commit CI trunk push 29 4m34s about 4 minutes ago
* cool commit CI trunk push 30 4m34s about 4 minutes ago
* cool commit CI trunk push 31 4m34s about 4 minutes ago
* cool commit CI trunk push 32 4m34s about 4 minutes ago
* cool commit CI trunk push 33 4m34s about 4 minutes ago
* cool commit CI trunk push 34 4m34s about 4 minutes ago
* cool commit CI trunk push 35 4m34s about 4 minutes ago
* cool commit CI trunk push 36 4m34s about 4 minutes ago
* cool commit CI trunk push 37 4m34s about 4 minutes ago
* cool commit CI trunk push 38 4m34s about 4 minutes ago
* cool commit CI trunk push 39 4m34s about 4 minutes ago
* cool commit CI trunk push 40 4m34s about 4 minutes ago
* cool commit CI trunk push 41 4m34s about 4 minutes ago
* cool commit CI trunk push 42 4m34s about 4 minutes ago
* cool commit CI trunk push 43 4m34s about 4 minutes ago
* cool commit CI trunk push 44 4m34s about 4 minutes ago
* cool commit CI trunk push 45 4m34s about 4 minutes ago
* cool commit CI trunk push 46 4m34s about 4 minutes ago
* cool commit CI trunk push 47 4m34s about 4 minutes ago
* cool commit CI trunk push 48 4m34s about 4 minutes ago
* cool commit CI trunk push 49 4m34s about 4 minutes ago
* cool commit CI trunk push 50 4m34s about 4 minutes ago
* cool commit CI trunk push 51 4m34s about 4 minutes ago
* cool commit CI trunk push 52 4m34s about 4 minutes ago
* cool commit CI trunk push 53 4m34s about 4 minutes ago
* cool commit CI trunk push 54 4m34s about 4 minutes ago
* cool commit CI trunk push 55 4m34s about 4 minutes ago
* cool commit CI trunk push 56 4m34s about 4 minutes ago
* cool commit CI trunk push 57 4m34s about 4 minutes ago
* cool commit CI trunk push 58 4m34s about 4 minutes ago
* cool commit CI trunk push 59 4m34s about 4 minutes ago
* cool commit CI trunk push 60 4m34s about 4 minutes ago
* cool commit CI trunk push 61 4m34s about 4 minutes ago
* cool commit CI trunk push 62 4m34s about 4 minutes ago
* cool commit CI trunk push 63 4m34s about 4 minutes ago
* cool commit CI trunk push 64 4m34s about 4 minutes ago
* cool commit CI trunk push 65 4m34s about 4 minutes ago
* cool commit CI trunk push 66 4m34s about 4 minutes ago
* cool commit CI trunk push 67 4m34s about 4 minutes ago
* cool commit CI trunk push 68 4m34s about 4 minutes ago
* cool commit CI trunk push 69 4m34s about 4 minutes ago
* cool commit CI trunk push 70 4m34s about 4 minutes ago
* cool commit CI trunk push 71 4m34s about 4 minutes ago
* cool commit CI trunk push 72 4m34s about 4 minutes ago
* cool commit CI trunk push 73 4m34s about 4 minutes ago
* cool commit CI trunk push 74 4m34s about 4 minutes ago
* cool commit CI trunk push 75 4m34s about 4 minutes ago
* cool commit CI trunk push 76 4m34s about 4 minutes ago
* cool commit CI trunk push 77 4m34s about 4 minutes ago
* cool commit CI trunk push 78 4m34s about 4 minutes ago
* cool commit CI trunk push 79 4m34s about 4 minutes ago
* cool commit CI trunk push 80 4m34s about 4 minutes ago
* cool commit CI trunk push 81 4m34s about 4 minutes ago
* cool commit CI trunk push 82 4m34s about 4 minutes ago
* cool commit CI trunk push 83 4m34s about 4 minutes ago
* cool commit CI trunk push 84 4m34s about 4 minutes ago
* cool commit CI trunk push 85 4m34s about 4 minutes ago
* cool commit CI trunk push 86 4m34s about 4 minutes ago
* cool commit CI trunk push 87 4m34s about 4 minutes ago
* cool commit CI trunk push 88 4m34s about 4 minutes ago
* cool commit CI trunk push 89 4m34s about 4 minutes ago
* cool commit CI trunk push 90 4m34s about 4 minutes ago
* cool commit CI trunk push 91 4m34s about 4 minutes ago
* cool commit CI trunk push 92 4m34s about 4 minutes ago
* cool commit CI trunk push 93 4m34s about 4 minutes ago
* cool commit CI trunk push 94 4m34s about 4 minutes ago
* cool commit CI trunk push 95 4m34s about 4 minutes ago
* cool commit CI trunk push 96 4m34s about 4 minutes ago
* cool commit CI trunk push 97 4m34s about 4 minutes ago
* cool commit CI trunk push 98 4m34s about 4 minutes ago
* cool commit CI trunk push 99 4m34s about 4 minutes ago
* cool commit CI trunk push 100 4m34s about 4 minutes ago
`),
},
{
@ -386,9 +386,9 @@ func TestListRun(t *testing.T) {
},
wantOut: heredoc.Doc(`
STATUS TITLE WORKFLOW BRANCH EVENT ID ELAPSED AGE
* cool commit a workflow trunk push 2 4m34s about 2 years ago
cool commit a workflow trunk push 3 4m34s about 2 years ago
X cool commit a workflow trunk push 1234 4m34s about 2 years ago
* cool commit a workflow trunk push 2 4m34s about 4 minute...
cool commit a workflow trunk push 3 4m34s about 4 minute...
X cool commit a workflow trunk push 1234 4m34s about 4 minute...
`),
},
{