Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mybee
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
mybee
Commits
d6667744
Unverified
Commit
d6667744
authored
Jan 06, 2021
by
Nemanja Zbiljić
Committed by
GitHub
Jan 06, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify JSON response extraction in tests (#1085)
parent
781f7330
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
5 additions
and
27 deletions
+5
-27
dirs_test.go
pkg/api/dirs_test.go
+2
-12
file_test.go
pkg/api/file_test.go
+0
-3
pin_bzz_test.go
pkg/api/pin_bzz_test.go
+3
-12
No files found.
pkg/api/dirs_test.go
View file @
d6667744
...
...
@@ -8,7 +8,6 @@ import (
"archive/tar"
"bytes"
"context"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
...
...
@@ -279,12 +278,12 @@ Disallow: /`),
// tar all the test case files
tarReader
:=
tarFiles
(
t
,
tc
.
files
)
var
resp
Bytes
[]
byt
e
var
resp
api
.
FileUploadRespons
e
options
:=
[]
jsonhttptest
.
Option
{
jsonhttptest
.
WithRequestBody
(
tarReader
),
jsonhttptest
.
WithRequestHeader
(
"Content-Type"
,
api
.
ContentTypeTar
),
jsonhttptest
.
With
PutResponseBody
(
&
respBytes
),
jsonhttptest
.
With
UnmarshalJSONResponse
(
&
resp
),
}
if
tc
.
indexFilenameOption
!=
nil
{
options
=
append
(
options
,
tc
.
indexFilenameOption
)
...
...
@@ -299,15 +298,6 @@ Disallow: /`),
// verify directory tar upload response
jsonhttptest
.
Request
(
t
,
client
,
http
.
MethodPost
,
dirUploadResource
,
http
.
StatusOK
,
options
...
)
read
:=
bytes
.
NewReader
(
respBytes
)
// get the reference
var
resp
api
.
FileUploadResponse
err
:=
json
.
NewDecoder
(
read
)
.
Decode
(
&
resp
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
if
resp
.
Reference
.
String
()
==
""
{
t
.
Fatalf
(
"expected file reference, did not got any"
)
}
...
...
pkg/api/file_test.go
View file @
d6667744
...
...
@@ -346,12 +346,9 @@ func TestRangeRequests(t *testing.T) {
uploadReference
:=
upload
.
reference
var
respBytes
[]
byte
jsonhttptest
.
Request
(
t
,
client
,
http
.
MethodPost
,
upload
.
uploadEndpoint
,
http
.
StatusOK
,
jsonhttptest
.
WithRequestBody
(
upload
.
reader
),
jsonhttptest
.
WithRequestHeader
(
"Content-Type"
,
upload
.
contentType
),
jsonhttptest
.
WithPutResponseBody
(
&
respBytes
),
)
for
_
,
tc
:=
range
ranges
{
...
...
pkg/api/pin_bzz_test.go
View file @
d6667744
...
...
@@ -5,8 +5,6 @@
package
api_test
import
(
"bytes"
"encoding/json"
"io/ioutil"
"net/http"
"testing"
...
...
@@ -71,20 +69,13 @@ func TestPinBzzHandler(t *testing.T) {
expectedChunkCount
:=
7
var
respBytes
[]
byte
// get the reference as everytime it will change because of random encryption key
var
resp
api
.
ListPinnedChunksResponse
jsonhttptest
.
Request
(
t
,
client
,
http
.
MethodGet
,
pinChunksResource
,
http
.
StatusOK
,
jsonhttptest
.
With
PutResponseBody
(
&
respBytes
),
jsonhttptest
.
With
UnmarshalJSONResponse
(
&
resp
),
)
read
:=
bytes
.
NewReader
(
respBytes
)
var
resp
api
.
ListPinnedChunksResponse
err
:=
json
.
NewDecoder
(
read
)
.
Decode
(
&
resp
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
if
expectedChunkCount
!=
len
(
resp
.
Chunks
)
{
t
.
Fatalf
(
"expected to find %d pinned chunks, got %d"
,
expectedChunkCount
,
len
(
resp
.
Chunks
))
}
...
...
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