epoch: fix unit test when SOURCE_DATE_EPOCH is set

Fixes https://github.com/containerd/containerd/issues/8200

Signed-off-by: Samuel Karp <samuelkarp@google.com>
This commit is contained in:
Samuel Karp
2023-03-03 14:54:23 -08:00
parent 7a77da2c26
commit 8ce3e4e159
2 changed files with 15 additions and 1 deletions

View File

@@ -34,7 +34,7 @@ const SourceDateEpochEnv = "SOURCE_DATE_EPOCH"
// If the env var is not set, SourceDateEpoch returns nil without an error.
func SourceDateEpoch() (*time.Time, error) {
v, ok := os.LookupEnv(SourceDateEpochEnv)
if !ok {
if !ok || v == "" {
return nil, nil // not an error
}
i64, err := strconv.ParseInt(v, 10, 64)