Skip to content

Commit c2b404c

Browse files
committed
epoch: fix unit test when SOURCE_DATE_EPOCH is set
Fixes #8200 Signed-off-by: Samuel Karp <[email protected]>
1 parent 7a77da2 commit c2b404c

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

pkg/epoch/epoch.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const SourceDateEpochEnv = "SOURCE_DATE_EPOCH"
3434
// If the env var is not set, SourceDateEpoch returns nil without an error.
3535
func SourceDateEpoch() (*time.Time, error) {
3636
v, ok := os.LookupEnv(SourceDateEpochEnv)
37-
if !ok {
37+
if !ok || v == "" {
3838
return nil, nil // not an error
3939
}
4040
i64, err := strconv.ParseInt(v, 10, 64)

pkg/epoch/epoch_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ func rightAfter(t1, t2 time.Time) bool {
3636
func TestSourceDateEpoch(t *testing.T) {
3737
if s, ok := os.LookupEnv(SourceDateEpochEnv); ok {
3838
t.Logf("%s is already set to %q, unsetting", SourceDateEpochEnv, s)
39+
// see https://github.com/golang/go/issues/52817#issuecomment-1131339120
3940
t.Setenv(SourceDateEpochEnv, "")
41+
os.Unsetenv(SourceDateEpochEnv)
4042
}
4143

4244
t.Run("WithoutSourceDateEpoch", func(t *testing.T) {

0 commit comments

Comments
 (0)