community/github-cli: fix failing test due to relative date

This commit is contained in:
Kevin Daudt 2024-03-06 18:07:12 +00:00
parent 9667876788
commit 375294811f
2 changed files with 294 additions and 0 deletions

View File

@ -20,6 +20,7 @@ subpackages="
"
source="https://github.com/cli/cli/archive/v$pkgver/github-cli-$pkgver.tar.gz
no-ignore-goflags.patch
test-fix-relative-dates.patch
"
builddir="$srcdir/cli-$pkgver"
@ -66,4 +67,5 @@ package() {
sha512sums="
7030284f41945b85124902b5ae720fcbb6e8fab763d82dd5886e7a4e53e4544234bfea128150c66eece3778858b52ec846c5e148b3e71d912c4324dc4974767b github-cli-2.39.2.tar.gz
57be81e57c0bb5c36e07b6ff2aab661f1a9cd0bbab3ef159c24d59098451858c44fce09d2f5eb86380044568a6acc46ed65b56a87f5a3dc4057d5579e8f420aa no-ignore-goflags.patch
fd460d19498b6685584ddbd5cf302ee951def9cf21d22f2b08ae19f207a3af60c8119b5f97e742ed7b98c5e570c01e30eca04d6cde182ef6da5f89c70e0c2155 test-fix-relative-dates.patch
"

View File

@ -0,0 +1,292 @@
From a9bdd8d186b619bd2415c2420c4c8bf9fe898c34 Mon Sep 17 00:00:00 2001
From: William Martin <williammartin@github.com>
Date: Wed, 13 Dec 2023 14:44:16 +0100
Subject: [PATCH] Fix flaky tests coupled to relative dates
---
pkg/cmd/cache/list/list.go | 4 +-
pkg/cmd/run/list/list.go | 2 +-
pkg/cmd/run/list/list_test.go | 228 +++++++++++++++++-----------------
3 files changed, 117 insertions(+), 117 deletions(-)
diff --git a/pkg/cmd/cache/list/list.go b/pkg/cmd/cache/list/list.go
index ab5d662b585..6920c2faa79 100644
--- a/pkg/cmd/cache/list/list.go
+++ b/pkg/cmd/cache/list/list.go
@@ -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()
}
diff --git a/pkg/cmd/run/list/list.go b/pkg/cmd/run/list/list.go
index 0913babf37d..1d9dad6b60a 100644
--- a/pkg/cmd/run/list/list.go
+++ b/pkg/cmd/run/list/list.go
@@ -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()
}
diff --git a/pkg/cmd/run/list/list_test.go b/pkg/cmd/run/list/list_test.go
index 1c306280489..762cc8cb77e 100644
--- a/pkg/cmd/run/list/list_test.go
+++ b/pkg/cmd/run/list/list_test.go
@@ -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...
`),
},
{