Skip to content

Commit 273acc9

Browse files
author
Sébastien HOUZÉ
committed
test: add modifed time test
1 parent 1218f58 commit 273acc9

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

internal/provider/archive-dir.zip

54 Bytes
Binary file not shown.

internal/provider/archive-file.zip

18 Bytes
Binary file not shown.

internal/provider/zip_archiver_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ func TestZipArchiver_FileModified(t *testing.T) {
9494
if !bytes.Equal(expectedContents, actualContents) {
9595
t.Fatalf("zip contents do not match, potentially a modified time issue")
9696
}
97+
98+
oldestZipSupportedModTime, _ := time.Parse(time.RFC3339, "1980-01-01T00:00:00+00:00")
99+
ensureModifiedtimes(t, zipFilePath, oldestZipSupportedModTime)
97100
}
98101

99102
func TestZipArchiver_Dir(t *testing.T) {
@@ -153,6 +156,20 @@ func TestZipArchiver_Multiple(t *testing.T) {
153156
ensureContents(t, zipfilepath, content)
154157
}
155158

159+
func ensureModifiedtimes(t *testing.T, zipfilepath string, modifiedTime time.Time) {
160+
r, err := zip.OpenReader(zipfilepath)
161+
if err != nil {
162+
t.Fatalf("could not open zip file: %s", err)
163+
}
164+
defer r.Close()
165+
166+
for _, cf := range r.File {
167+
if !cf.Modified.Equal(modifiedTime) {
168+
t.Fatalf("Modified time does not match, got %s, want %s", cf.Modified, modifiedTime)
169+
}
170+
}
171+
}
172+
156173
func ensureContents(t *testing.T, zipfilepath string, wants map[string][]byte) {
157174
t.Helper()
158175
r, err := zip.OpenReader(zipfilepath)

0 commit comments

Comments
 (0)