Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-workhorse
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
iv
gitlab-workhorse
Commits
d76b7599
Commit
d76b7599
authored
Jan 26, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add specs for generated artifacts metadata paths
parent
53e345d2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
2 deletions
+42
-2
internal/zipartifacts/metadata.go
internal/zipartifacts/metadata.go
+2
-2
internal/zipartifacts/metadata_test.go
internal/zipartifacts/metadata_test.go
+40
-0
No files found.
internal/zipartifacts/metadata.go
View file @
d76b7599
...
...
@@ -77,8 +77,8 @@ func generateZipMetadata(output io.Writer, archive *zip.Reader) error {
for
_
,
entry
:=
range
archive
.
File
{
zipMap
[
entry
.
Name
]
=
entry
for
entryPath
:=
path
.
Dir
(
entry
.
Name
);
entryPath
!=
"."
&&
entryPath
!=
"/"
;
entryPath
=
path
.
Dir
(
entryPath
)
{
entryDir
:=
entryPath
+
"/"
for
d
:=
path
.
Dir
(
entry
.
Name
);
d
!=
"."
&&
d
!=
"/"
;
d
=
path
.
Dir
(
d
)
{
entryDir
:=
d
+
"/"
if
_
,
ok
:=
zipMap
[
entryDir
];
!
ok
{
zipMap
[
entryDir
]
=
nil
}
...
...
internal/zipartifacts/metadata_test.go
0 → 100644
View file @
d76b7599
package
zipartifacts
import
(
"archive/zip"
"bytes"
"encoding/binary"
"fmt"
"testing"
)
func
TestMissingMetadataEntries
(
t
*
testing
.
T
)
{
var
zipBuffer
,
metaBuffer
bytes
.
Buffer
archive
:=
zip
.
NewWriter
(
&
zipBuffer
)
firstFile
,
err
:=
archive
.
Create
(
"file1"
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
fmt
.
Fprint
(
firstFile
,
"test12"
)
secondFile
,
err
:=
archive
.
Create
(
"some/file/dir/file2"
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
fmt
.
Fprint
(
secondFile
,
"test125678"
)
archive
.
Close
()
zipReader
:=
bytes
.
NewReader
(
zipBuffer
.
Bytes
())
zipArchiveReader
,
_
:=
zip
.
NewReader
(
zipReader
,
int64
(
binary
.
Size
(
zipBuffer
.
Bytes
())))
err
=
generateZipMetadata
(
&
metaBuffer
,
zipArchiveReader
)
paths
:=
[]
string
{
"file1"
,
"some/"
,
"some/file/"
,
"some/file/dir"
,
"some/file/dir/file2"
}
for
_
,
path
:=
range
paths
{
if
!
bytes
.
Contains
(
metaBuffer
.
Bytes
(),
[]
byte
(
path
))
{
t
.
Fatalf
(
"zipartifacts: metadata for path %s not found!"
,
path
)
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment