Skip to content

Commit 5ce1bea

Browse files
author
Sébastien HOUZÉ
committed
test: add modifed time test
1 parent 1b9e6d8 commit 5ce1bea

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
@@ -69,6 +69,9 @@ func TestZipArchiver_FileModified(t *testing.T) {
6969
if !bytes.Equal(expectedContents, actualContents) {
7070
t.Fatalf("zip contents do not match, potentially a modified time issue")
7171
}
72+
73+
oldestZipSupportedModTime, _ := time.Parse(time.RFC3339, "1980-01-01T00:00:00+00:00")
74+
ensureModifiedtimes(t, zipFilePath, oldestZipSupportedModTime)
7275
}
7376

7477
func TestZipArchiver_Dir(t *testing.T) {
@@ -129,6 +132,20 @@ func TestZipArchiver_Multiple(t *testing.T) {
129132

130133
}
131134

135+
func ensureModifiedtimes(t *testing.T, zipfilepath string, modifiedTime time.Time) {
136+
r, err := zip.OpenReader(zipfilepath)
137+
if err != nil {
138+
t.Fatalf("could not open zip file: %s", err)
139+
}
140+
defer r.Close()
141+
142+
for _, cf := range r.File {
143+
if !cf.Modified.Equal(modifiedTime) {
144+
t.Fatalf("Modified time does not match, got %s, want %s", cf.Modified, modifiedTime)
145+
}
146+
}
147+
}
148+
132149
func ensureContents(t *testing.T, zipfilepath string, wants map[string][]byte) {
133150
r, err := zip.OpenReader(zipfilepath)
134151
if err != nil {

0 commit comments

Comments
 (0)