From abf2cae466ebe09e28c709e6081b1bc6f0da26d1 Mon Sep 17 00:00:00 2001 From: Tanmay Chaudhry <tanmay.chaudhry@gmail.com> Date: Mon, 17 Apr 2023 11:31:10 +0530 Subject: [PATCH 1/3] switch the TZ to UTC temporarily for running the tests --- pkg/news/news_test.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/news/news_test.go b/pkg/news/news_test.go index 70b570ebc..713105f6b 100644 --- a/pkg/news/news_test.go +++ b/pkg/news/news_test.go @@ -121,6 +121,9 @@ func TestPrintNewsFeed(t *testing.T) { {name: "latest-quiet", args: args{bottomUp: true, cutOffDate: lastNewsTime, all: false, quiet: true}, wantErr: false}, {name: "latest-quiet-topdown", args: args{bottomUp: false, cutOffDate: lastNewsTime, all: false, quiet: true}, wantErr: false}, } + currentTZ := os.Getenv("TZ") + defer os.Setenv("TZ", currentTZ) + os.Setenv("TZ", "UTC") for _, tt := range tests { tt := tt t.Run(tt.name, func(t *testing.T) { From a3c3dd4b308f58829c3ae08745d366cfff8e4720 Mon Sep 17 00:00:00 2001 From: Tanmay Chaudhry <tanmay.chaudhry@gmail.com> Date: Mon, 17 Apr 2023 15:15:30 +0530 Subject: [PATCH 2/3] Remove unnecessary environment reset --- pkg/news/news_test.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/pkg/news/news_test.go b/pkg/news/news_test.go index 713105f6b..b61b3769a 100644 --- a/pkg/news/news_test.go +++ b/pkg/news/news_test.go @@ -121,8 +121,6 @@ func TestPrintNewsFeed(t *testing.T) { {name: "latest-quiet", args: args{bottomUp: true, cutOffDate: lastNewsTime, all: false, quiet: true}, wantErr: false}, {name: "latest-quiet-topdown", args: args{bottomUp: false, cutOffDate: lastNewsTime, all: false, quiet: true}, wantErr: false}, } - currentTZ := os.Getenv("TZ") - defer os.Setenv("TZ", currentTZ) os.Setenv("TZ", "UTC") for _, tt := range tests { tt := tt From 1468b8f6a855a66e6d13655503c65f48de8f385f Mon Sep 17 00:00:00 2001 From: Tanmay Chaudhry <tanmay.chaudhry@gmail.com> Date: Mon, 17 Apr 2023 18:48:52 +0530 Subject: [PATCH 3/3] Set test specific environment. Co-authored-by: Jo <me@jguer.space> --- pkg/news/news_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/news/news_test.go b/pkg/news/news_test.go index b61b3769a..2afeccea3 100644 --- a/pkg/news/news_test.go +++ b/pkg/news/news_test.go @@ -121,7 +121,7 @@ func TestPrintNewsFeed(t *testing.T) { {name: "latest-quiet", args: args{bottomUp: true, cutOffDate: lastNewsTime, all: false, quiet: true}, wantErr: false}, {name: "latest-quiet-topdown", args: args{bottomUp: false, cutOffDate: lastNewsTime, all: false, quiet: true}, wantErr: false}, } - os.Setenv("TZ", "UTC") + t.Setenv("TZ", "UTC") for _, tt := range tests { tt := tt t.Run(tt.name, func(t *testing.T) {