Skip to content

Commit

Permalink
Upload - Add timezone to each zip file before uploading (#2103)
Browse files Browse the repository at this point in the history
  • Loading branch information
Or-Geva authored Sep 27, 2023
1 parent b04accc commit c958add
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions artifactory_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"archive/zip"
"bytes"
"crypto/tls"
"encoding/csv"
Expand Down Expand Up @@ -4166,6 +4167,38 @@ func TestUploadDeploymentViewWithArchive(t *testing.T) {
cleanArtifactoryTest()
}

func TestUploadZipAndCheckDeploymentViewWithArchive(t *testing.T) {
initArtifactoryTest(t, "")

// Create tmp dir
assert.NoError(t, os.Mkdir(tests.Out, 0755))
wd, err := os.Getwd()
assert.NoError(t, err)
defer cleanArtifactoryTest()
chdirCallback := clientTestUtils.ChangeDirWithCallback(t, wd, tests.Out)
defer chdirCallback()

// Create file and a zip
fileName := "dummy_file.txt"
zipName := "test.zip"
assert.NoError(t, os.WriteFile(fileName, nil, 0644))

// Upload & download zip file
assert.NoError(t, artifactoryCli.Exec("upload", fileName, path.Join(tests.RtRepo1, zipName), "--archive", "zip"))
assert.NoError(t, artifactoryCli.Exec("download", path.Join(tests.RtRepo1, zipName)))

// Check for time-zone offset for each file in the zip
r, err := zip.OpenReader(zipName)
assert.NoError(t, err)
defer func() { assert.NoError(t, r.Close()) }()
_, sysTimezoneOffset := time.Now().Zone()
for _, file := range r.File {
_, fileTimezoneOffset := file.Modified.Zone()
assert.Equal(t, sysTimezoneOffset, fileTimezoneOffset)
}

}

func TestUploadDetailedSummary(t *testing.T) {
initArtifactoryTest(t, "")
uploadCmd := generic.NewUploadCommand()
Expand Down

0 comments on commit c958add

Please sign in to comment.