Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
ac5d2cec
Commit
ac5d2cec
authored
May 09, 2016
by
Wojciech Tyczynski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test if headers are set
parent
cd3ab5d8
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
6 deletions
+27
-6
request_test.go
pkg/client/restclient/request_test.go
+27
-6
No files found.
pkg/client/restclient/request_test.go
View file @
ac5d2cec
...
@@ -58,6 +58,33 @@ func TestNewRequestSetsAccept(t *testing.T) {
...
@@ -58,6 +58,33 @@ func TestNewRequestSetsAccept(t *testing.T) {
}
}
}
}
type
clientFunc
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
func
(
f
clientFunc
)
Do
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
return
f
(
req
)
}
func
TestRequestSetsHeaders
(
t
*
testing
.
T
)
{
server
:=
clientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
if
req
.
Header
.
Get
(
"Accept"
)
!=
"application/other, */*"
{
t
.
Errorf
(
"unexpected headers: %#v"
,
req
.
Header
)
}
return
&
http
.
Response
{
StatusCode
:
http
.
StatusForbidden
,
Body
:
ioutil
.
NopCloser
(
bytes
.
NewReader
([]
byte
{})),
},
nil
})
config
:=
defaultContentConfig
()
config
.
ContentType
=
"application/other"
serializers
:=
defaultSerializers
()
r
:=
NewRequest
(
server
,
"get"
,
&
url
.
URL
{
Path
:
"/path"
},
""
,
config
,
serializers
,
nil
,
nil
)
// Check if all "issue" methods are setting headers.
_
=
r
.
Do
()
_
,
_
=
r
.
Watch
()
_
,
_
=
r
.
Stream
()
}
func
TestRequestWithErrorWontChange
(
t
*
testing
.
T
)
{
func
TestRequestWithErrorWontChange
(
t
*
testing
.
T
)
{
original
:=
Request
{
original
:=
Request
{
err
:
errors
.
New
(
"test"
),
err
:
errors
.
New
(
"test"
),
...
@@ -463,12 +490,6 @@ func TestTransformUnstructuredError(t *testing.T) {
...
@@ -463,12 +490,6 @@ func TestTransformUnstructuredError(t *testing.T) {
}
}
}
}
type
clientFunc
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
func
(
f
clientFunc
)
Do
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
return
f
(
req
)
}
func
TestRequestWatch
(
t
*
testing
.
T
)
{
func
TestRequestWatch
(
t
*
testing
.
T
)
{
testCases
:=
[]
struct
{
testCases
:=
[]
struct
{
Request
*
Request
Request
*
Request
...
...
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