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
1
Merge Requests
1
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
nexedi
gitlab-workhorse
Commits
10f23d51
Commit
10f23d51
authored
May 27, 2020
by
Jacob Vosmaer
Committed by
Nick Thomas
Jun 04, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test for reading artifact zips over HTTP
parent
a6e22900
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
0 deletions
+56
-0
internal/zipartifacts/.gitignore
internal/zipartifacts/.gitignore
+1
-0
internal/zipartifacts/open_archive_test.go
internal/zipartifacts/open_archive_test.go
+55
-0
No files found.
internal/zipartifacts/.gitignore
0 → 100644
View file @
10f23d51
/testdata
internal/zipartifacts/open_archive_test.go
0 → 100644
View file @
10f23d51
package
zipartifacts
import
(
"archive/zip"
"context"
"fmt"
"io/ioutil"
"net/http"
"net/http/httptest"
"os"
"path/filepath"
"testing"
"github.com/stretchr/testify/require"
)
func
TestOpenHTTPArchive
(
t
*
testing
.
T
)
{
const
(
zipFile
=
"test.zip"
entryName
=
"hello.txt"
contents
=
"world"
testRoot
=
"testdata/public"
)
require
.
NoError
(
t
,
os
.
MkdirAll
(
testRoot
,
0755
))
f
,
err
:=
os
.
Create
(
filepath
.
Join
(
testRoot
,
zipFile
))
require
.
NoError
(
t
,
err
,
"create file"
)
defer
f
.
Close
()
zw
:=
zip
.
NewWriter
(
f
)
w
,
err
:=
zw
.
Create
(
entryName
)
require
.
NoError
(
t
,
err
,
"create zip entry"
)
_
,
err
=
fmt
.
Fprint
(
w
,
contents
)
require
.
NoError
(
t
,
err
,
"write zip entry contents"
)
require
.
NoError
(
t
,
zw
.
Close
(),
"close zip writer"
)
require
.
NoError
(
t
,
f
.
Close
(),
"close file"
)
srv
:=
httptest
.
NewServer
(
http
.
FileServer
(
http
.
Dir
(
testRoot
)))
defer
srv
.
Close
()
zr
,
err
:=
OpenArchive
(
context
.
Background
(),
srv
.
URL
+
"/"
+
zipFile
)
require
.
NoError
(
t
,
err
,
"call OpenArchive"
)
require
.
Len
(
t
,
zr
.
File
,
1
)
zf
:=
zr
.
File
[
0
]
require
.
Equal
(
t
,
entryName
,
zf
.
Name
,
"zip entry name"
)
entry
,
err
:=
zf
.
Open
()
require
.
NoError
(
t
,
err
,
"get zip entry reader"
)
defer
entry
.
Close
()
actualContents
,
err
:=
ioutil
.
ReadAll
(
entry
)
require
.
NoError
(
t
,
err
,
"read zip entry contents"
)
require
.
Equal
(
t
,
contents
,
string
(
actualContents
),
"compare zip entry contents"
)
}
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