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
02e1a2e7
Commit
02e1a2e7
authored
Sep 30, 2014
by
derekwaynecarr
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update unit tests to pass a context on client create
parent
b7b11939
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
53 additions
and
37 deletions
+53
-37
client_test.go
pkg/client/client_test.go
+12
-7
request_test.go
pkg/client/request_test.go
+24
-13
replication_controller_test.go
pkg/controller/replication_controller_test.go
+5
-5
endpoints_controller_test.go
pkg/service/endpoints_controller_test.go
+6
-6
factory_test.go
plugin/pkg/scheduler/factory/factory_test.go
+6
-6
No files found.
pkg/client/client_test.go
View file @
02e1a2e7
...
@@ -49,8 +49,9 @@ func TestChecksCodec(t *testing.T) {
...
@@ -49,8 +49,9 @@ func TestChecksCodec(t *testing.T) {
"v1beta2"
:
{
false
,
"/api/v1beta2/"
,
v1beta2
.
Codec
},
"v1beta2"
:
{
false
,
"/api/v1beta2/"
,
v1beta2
.
Codec
},
"v1beta3"
:
{
true
,
""
,
nil
},
"v1beta3"
:
{
true
,
""
,
nil
},
}
}
ctx
:=
api
.
NewContext
()
for
version
,
expected
:=
range
testCases
{
for
version
,
expected
:=
range
testCases
{
client
,
err
:=
New
(
"127.0.0.1"
,
version
,
nil
)
client
,
err
:=
New
(
ctx
,
"127.0.0.1"
,
version
,
nil
)
switch
{
switch
{
case
err
==
nil
&&
expected
.
Err
:
case
err
==
nil
&&
expected
.
Err
:
t
.
Errorf
(
"expected error but was nil"
)
t
.
Errorf
(
"expected error but was nil"
)
...
@@ -82,8 +83,9 @@ func TestValidatesHostParameter(t *testing.T) {
...
@@ -82,8 +83,9 @@ func TestValidatesHostParameter(t *testing.T) {
"http://host/server"
:
{
"http://host"
,
"/server/api/v1beta1/"
,
false
},
"http://host/server"
:
{
"http://host"
,
"/server/api/v1beta1/"
,
false
},
"host/server"
:
{
""
,
""
,
true
},
"host/server"
:
{
""
,
""
,
true
},
}
}
ctx
:=
api
.
NewContext
()
for
k
,
expected
:=
range
testCases
{
for
k
,
expected
:=
range
testCases
{
c
,
err
:=
NewRESTClient
(
k
,
nil
,
"/api/v1beta1/"
,
v1beta1
.
Codec
)
c
,
err
:=
NewRESTClient
(
ctx
,
k
,
nil
,
"/api/v1beta1/"
,
v1beta1
.
Codec
)
switch
{
switch
{
case
err
==
nil
&&
expected
.
Err
:
case
err
==
nil
&&
expected
.
Err
:
t
.
Errorf
(
"expected error but was nil"
)
t
.
Errorf
(
"expected error but was nil"
)
...
@@ -381,6 +383,7 @@ type testClient struct {
...
@@ -381,6 +383,7 @@ type testClient struct {
}
}
func
(
c
*
testClient
)
Setup
()
*
testClient
{
func
(
c
*
testClient
)
Setup
()
*
testClient
{
ctx
:=
api
.
NewContext
()
c
.
handler
=
&
util
.
FakeHandler
{
c
.
handler
=
&
util
.
FakeHandler
{
StatusCode
:
c
.
Response
.
StatusCode
,
StatusCode
:
c
.
Response
.
StatusCode
,
}
}
...
@@ -389,7 +392,7 @@ func (c *testClient) Setup() *testClient {
...
@@ -389,7 +392,7 @@ func (c *testClient) Setup() *testClient {
}
}
c
.
server
=
httptest
.
NewServer
(
c
.
handler
)
c
.
server
=
httptest
.
NewServer
(
c
.
handler
)
if
c
.
Client
==
nil
{
if
c
.
Client
==
nil
{
c
.
Client
=
NewOrDie
(
"localhost"
,
"v1beta1"
,
nil
)
c
.
Client
=
NewOrDie
(
ctx
,
"localhost"
,
"v1beta1"
,
nil
)
}
}
c
.
Client
.
host
=
c
.
server
.
URL
c
.
Client
.
host
=
c
.
server
.
URL
c
.
Client
.
prefix
=
"/api/v1beta1/"
c
.
Client
.
prefix
=
"/api/v1beta1/"
...
@@ -573,7 +576,7 @@ func TestDoRequest(t *testing.T) {
...
@@ -573,7 +576,7 @@ func TestDoRequest(t *testing.T) {
testClients
:=
[]
testClient
{
testClients
:=
[]
testClient
{
{
Request
:
testRequest
{
Method
:
"GET"
,
Path
:
"good"
},
Response
:
Response
{
StatusCode
:
200
}},
{
Request
:
testRequest
{
Method
:
"GET"
,
Path
:
"good"
},
Response
:
Response
{
StatusCode
:
200
}},
{
Request
:
testRequest
{
Method
:
"GET"
,
Path
:
"bad%ZZ"
},
Error
:
true
},
{
Request
:
testRequest
{
Method
:
"GET"
,
Path
:
"bad%ZZ"
},
Error
:
true
},
{
Client
:
NewOrDie
(
"localhost"
,
"v1beta1"
,
&
AuthInfo
{
"foo"
,
"bar"
,
""
,
""
,
""
}),
Request
:
testRequest
{
Method
:
"GET"
,
Path
:
"auth"
,
Header
:
"Authorization"
},
Response
:
Response
{
StatusCode
:
200
}},
{
Client
:
NewOrDie
(
api
.
NewContext
(),
"localhost"
,
"v1beta1"
,
&
AuthInfo
{
"foo"
,
"bar"
,
""
,
""
,
""
}),
Request
:
testRequest
{
Method
:
"GET"
,
Path
:
"auth"
,
Header
:
"Authorization"
},
Response
:
Response
{
StatusCode
:
200
}},
{
Client
:
&
Client
{
&
RESTClient
{
httpClient
:
http
.
DefaultClient
}},
Request
:
testRequest
{
Method
:
"GET"
,
Path
:
"nocertificate"
},
Error
:
true
},
{
Client
:
&
Client
{
&
RESTClient
{
httpClient
:
http
.
DefaultClient
}},
Request
:
testRequest
{
Method
:
"GET"
,
Path
:
"nocertificate"
},
Error
:
true
},
{
Request
:
testRequest
{
Method
:
"GET"
,
Path
:
"error"
},
Response
:
Response
{
StatusCode
:
500
},
Error
:
true
},
{
Request
:
testRequest
{
Method
:
"GET"
,
Path
:
"error"
},
Response
:
Response
{
StatusCode
:
500
},
Error
:
true
},
{
Request
:
testRequest
{
Method
:
"POST"
,
Path
:
"faildecode"
},
Response
:
Response
{
StatusCode
:
200
,
RawBody
:
&
invalid
}},
{
Request
:
testRequest
{
Method
:
"POST"
,
Path
:
"faildecode"
},
Response
:
Response
{
StatusCode
:
200
,
RawBody
:
&
invalid
}},
...
@@ -604,7 +607,8 @@ func TestDoRequestAccepted(t *testing.T) {
...
@@ -604,7 +607,8 @@ func TestDoRequestAccepted(t *testing.T) {
testServer
:=
httptest
.
NewServer
(
&
fakeHandler
)
testServer
:=
httptest
.
NewServer
(
&
fakeHandler
)
request
,
_
:=
http
.
NewRequest
(
"GET"
,
testServer
.
URL
+
"/foo/bar"
,
nil
)
request
,
_
:=
http
.
NewRequest
(
"GET"
,
testServer
.
URL
+
"/foo/bar"
,
nil
)
auth
:=
AuthInfo
{
User
:
"user"
,
Password
:
"pass"
}
auth
:=
AuthInfo
{
User
:
"user"
,
Password
:
"pass"
}
c
,
err
:=
New
(
testServer
.
URL
,
""
,
&
auth
)
ctx
:=
api
.
NewContext
()
c
,
err
:=
New
(
ctx
,
testServer
.
URL
,
""
,
&
auth
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
}
}
...
@@ -641,7 +645,8 @@ func TestDoRequestAcceptedSuccess(t *testing.T) {
...
@@ -641,7 +645,8 @@ func TestDoRequestAcceptedSuccess(t *testing.T) {
testServer
:=
httptest
.
NewServer
(
&
fakeHandler
)
testServer
:=
httptest
.
NewServer
(
&
fakeHandler
)
request
,
_
:=
http
.
NewRequest
(
"GET"
,
testServer
.
URL
+
"/foo/bar"
,
nil
)
request
,
_
:=
http
.
NewRequest
(
"GET"
,
testServer
.
URL
+
"/foo/bar"
,
nil
)
auth
:=
AuthInfo
{
User
:
"user"
,
Password
:
"pass"
}
auth
:=
AuthInfo
{
User
:
"user"
,
Password
:
"pass"
}
c
,
err
:=
New
(
testServer
.
URL
,
""
,
&
auth
)
ctx
:=
api
.
NewContext
()
c
,
err
:=
New
(
ctx
,
testServer
.
URL
,
""
,
&
auth
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
}
}
...
@@ -678,7 +683,7 @@ func TestGetServerVersion(t *testing.T) {
...
@@ -678,7 +683,7 @@ func TestGetServerVersion(t *testing.T) {
w
.
WriteHeader
(
http
.
StatusOK
)
w
.
WriteHeader
(
http
.
StatusOK
)
w
.
Write
(
output
)
w
.
Write
(
output
)
}))
}))
client
:=
NewOrDie
(
server
.
URL
,
""
,
nil
)
client
:=
NewOrDie
(
api
.
NewContext
(),
server
.
URL
,
""
,
nil
)
got
,
err
:=
client
.
ServerVersion
()
got
,
err
:=
client
.
ServerVersion
()
if
err
!=
nil
{
if
err
!=
nil
{
...
...
pkg/client/request_test.go
View file @
02e1a2e7
...
@@ -49,7 +49,8 @@ func TestDoRequestNewWay(t *testing.T) {
...
@@ -49,7 +49,8 @@ func TestDoRequestNewWay(t *testing.T) {
}
}
testServer
:=
httptest
.
NewServer
(
&
fakeHandler
)
testServer
:=
httptest
.
NewServer
(
&
fakeHandler
)
auth
:=
AuthInfo
{
User
:
"user"
,
Password
:
"pass"
}
auth
:=
AuthInfo
{
User
:
"user"
,
Password
:
"pass"
}
c
:=
NewOrDie
(
testServer
.
URL
,
"v1beta2"
,
&
auth
)
ctx
:=
api
.
NewContext
()
c
:=
NewOrDie
(
ctx
,
testServer
.
URL
,
"v1beta2"
,
&
auth
)
obj
,
err
:=
c
.
Verb
(
"POST"
)
.
obj
,
err
:=
c
.
Verb
(
"POST"
)
.
Path
(
"foo/bar"
)
.
Path
(
"foo/bar"
)
.
Path
(
"baz"
)
.
Path
(
"baz"
)
.
...
@@ -84,7 +85,8 @@ func TestDoRequestNewWayReader(t *testing.T) {
...
@@ -84,7 +85,8 @@ func TestDoRequestNewWayReader(t *testing.T) {
}
}
testServer
:=
httptest
.
NewServer
(
&
fakeHandler
)
testServer
:=
httptest
.
NewServer
(
&
fakeHandler
)
auth
:=
AuthInfo
{
User
:
"user"
,
Password
:
"pass"
}
auth
:=
AuthInfo
{
User
:
"user"
,
Password
:
"pass"
}
c
:=
NewOrDie
(
testServer
.
URL
,
"v1beta1"
,
&
auth
)
ctx
:=
api
.
NewContext
()
c
:=
NewOrDie
(
ctx
,
testServer
.
URL
,
"v1beta1"
,
&
auth
)
obj
,
err
:=
c
.
Verb
(
"POST"
)
.
obj
,
err
:=
c
.
Verb
(
"POST"
)
.
Path
(
"foo/bar"
)
.
Path
(
"foo/bar"
)
.
Path
(
"baz"
)
.
Path
(
"baz"
)
.
...
@@ -121,7 +123,8 @@ func TestDoRequestNewWayObj(t *testing.T) {
...
@@ -121,7 +123,8 @@ func TestDoRequestNewWayObj(t *testing.T) {
}
}
testServer
:=
httptest
.
NewServer
(
&
fakeHandler
)
testServer
:=
httptest
.
NewServer
(
&
fakeHandler
)
auth
:=
AuthInfo
{
User
:
"user"
,
Password
:
"pass"
}
auth
:=
AuthInfo
{
User
:
"user"
,
Password
:
"pass"
}
c
:=
NewOrDie
(
testServer
.
URL
,
"v1beta2"
,
&
auth
)
ctx
:=
api
.
NewContext
()
c
:=
NewOrDie
(
ctx
,
testServer
.
URL
,
"v1beta2"
,
&
auth
)
obj
,
err
:=
c
.
Verb
(
"POST"
)
.
obj
,
err
:=
c
.
Verb
(
"POST"
)
.
Path
(
"foo/bar"
)
.
Path
(
"foo/bar"
)
.
Path
(
"baz"
)
.
Path
(
"baz"
)
.
...
@@ -171,7 +174,8 @@ func TestDoRequestNewWayFile(t *testing.T) {
...
@@ -171,7 +174,8 @@ func TestDoRequestNewWayFile(t *testing.T) {
}
}
testServer
:=
httptest
.
NewServer
(
&
fakeHandler
)
testServer
:=
httptest
.
NewServer
(
&
fakeHandler
)
auth
:=
AuthInfo
{
User
:
"user"
,
Password
:
"pass"
}
auth
:=
AuthInfo
{
User
:
"user"
,
Password
:
"pass"
}
c
:=
NewOrDie
(
testServer
.
URL
,
"v1beta1"
,
&
auth
)
ctx
:=
api
.
NewContext
()
c
:=
NewOrDie
(
ctx
,
testServer
.
URL
,
"v1beta1"
,
&
auth
)
obj
,
err
:=
c
.
Verb
(
"POST"
)
.
obj
,
err
:=
c
.
Verb
(
"POST"
)
.
Path
(
"foo/bar"
)
.
Path
(
"foo/bar"
)
.
Path
(
"baz"
)
.
Path
(
"baz"
)
.
...
@@ -196,7 +200,8 @@ func TestDoRequestNewWayFile(t *testing.T) {
...
@@ -196,7 +200,8 @@ func TestDoRequestNewWayFile(t *testing.T) {
}
}
func
TestVerbs
(
t
*
testing
.
T
)
{
func
TestVerbs
(
t
*
testing
.
T
)
{
c
:=
NewOrDie
(
"localhost"
,
""
,
nil
)
ctx
:=
api
.
NewContext
()
c
:=
NewOrDie
(
ctx
,
"localhost"
,
""
,
nil
)
if
r
:=
c
.
Post
();
r
.
verb
!=
"POST"
{
if
r
:=
c
.
Post
();
r
.
verb
!=
"POST"
{
t
.
Errorf
(
"Post verb is wrong"
)
t
.
Errorf
(
"Post verb is wrong"
)
}
}
...
@@ -212,8 +217,9 @@ func TestVerbs(t *testing.T) {
...
@@ -212,8 +217,9 @@ func TestVerbs(t *testing.T) {
}
}
func
TestAbsPath
(
t
*
testing
.
T
)
{
func
TestAbsPath
(
t
*
testing
.
T
)
{
ctx
:=
api
.
NewContext
()
expectedPath
:=
"/bar/foo"
expectedPath
:=
"/bar/foo"
c
:=
NewOrDie
(
"localhost"
,
""
,
nil
)
c
:=
NewOrDie
(
ctx
,
"localhost"
,
""
,
nil
)
r
:=
c
.
Post
()
.
Path
(
"/foo"
)
.
AbsPath
(
expectedPath
)
r
:=
c
.
Post
()
.
Path
(
"/foo"
)
.
AbsPath
(
expectedPath
)
if
r
.
path
!=
expectedPath
{
if
r
.
path
!=
expectedPath
{
t
.
Errorf
(
"unexpected path: %s, expected %s"
,
r
.
path
,
expectedPath
)
t
.
Errorf
(
"unexpected path: %s, expected %s"
,
r
.
path
,
expectedPath
)
...
@@ -221,7 +227,8 @@ func TestAbsPath(t *testing.T) {
...
@@ -221,7 +227,8 @@ func TestAbsPath(t *testing.T) {
}
}
func
TestSync
(
t
*
testing
.
T
)
{
func
TestSync
(
t
*
testing
.
T
)
{
c
:=
NewOrDie
(
"localhost"
,
""
,
nil
)
ctx
:=
api
.
NewContext
()
c
:=
NewOrDie
(
ctx
,
"localhost"
,
""
,
nil
)
r
:=
c
.
Get
()
r
:=
c
.
Get
()
if
r
.
sync
{
if
r
.
sync
{
t
.
Errorf
(
"sync has wrong default"
)
t
.
Errorf
(
"sync has wrong default"
)
...
@@ -247,8 +254,9 @@ func TestUintParam(t *testing.T) {
...
@@ -247,8 +254,9 @@ func TestUintParam(t *testing.T) {
{
"baz"
,
0
,
"http://localhost?baz=0"
},
{
"baz"
,
0
,
"http://localhost?baz=0"
},
}
}
ctx
:=
api
.
NewContext
()
for
_
,
item
:=
range
table
{
for
_
,
item
:=
range
table
{
c
:=
NewOrDie
(
"localhost"
,
""
,
nil
)
c
:=
NewOrDie
(
ctx
,
"localhost"
,
""
,
nil
)
r
:=
c
.
Get
()
.
AbsPath
(
""
)
.
UintParam
(
item
.
name
,
item
.
testVal
)
r
:=
c
.
Get
()
.
AbsPath
(
""
)
.
UintParam
(
item
.
name
,
item
.
testVal
)
if
e
,
a
:=
item
.
expectStr
,
r
.
finalURL
();
e
!=
a
{
if
e
,
a
:=
item
.
expectStr
,
r
.
finalURL
();
e
!=
a
{
t
.
Errorf
(
"expected %v, got %v"
,
e
,
a
)
t
.
Errorf
(
"expected %v, got %v"
,
e
,
a
)
...
@@ -265,9 +273,9 @@ func TestUnacceptableParamNames(t *testing.T) {
...
@@ -265,9 +273,9 @@ func TestUnacceptableParamNames(t *testing.T) {
{
"sync"
,
"foo"
,
false
},
{
"sync"
,
"foo"
,
false
},
{
"timeout"
,
"42"
,
false
},
{
"timeout"
,
"42"
,
false
},
}
}
ctx
:=
api
.
NewContext
()
for
_
,
item
:=
range
table
{
for
_
,
item
:=
range
table
{
c
:=
NewOrDie
(
"localhost"
,
""
,
nil
)
c
:=
NewOrDie
(
ctx
,
"localhost"
,
""
,
nil
)
r
:=
c
.
Get
()
.
setParam
(
item
.
name
,
item
.
testVal
)
r
:=
c
.
Get
()
.
setParam
(
item
.
name
,
item
.
testVal
)
if
e
,
a
:=
item
.
expectSuccess
,
r
.
err
==
nil
;
e
!=
a
{
if
e
,
a
:=
item
.
expectSuccess
,
r
.
err
==
nil
;
e
!=
a
{
t
.
Errorf
(
"expected %v, got %v (%v)"
,
e
,
a
,
r
.
err
)
t
.
Errorf
(
"expected %v, got %v (%v)"
,
e
,
a
,
r
.
err
)
...
@@ -276,7 +284,8 @@ func TestUnacceptableParamNames(t *testing.T) {
...
@@ -276,7 +284,8 @@ func TestUnacceptableParamNames(t *testing.T) {
}
}
func
TestSetPollPeriod
(
t
*
testing
.
T
)
{
func
TestSetPollPeriod
(
t
*
testing
.
T
)
{
c
:=
NewOrDie
(
"localhost"
,
""
,
nil
)
ctx
:=
api
.
NewContext
()
c
:=
NewOrDie
(
ctx
,
"localhost"
,
""
,
nil
)
r
:=
c
.
Get
()
r
:=
c
.
Get
()
if
r
.
pollPeriod
==
0
{
if
r
.
pollPeriod
==
0
{
t
.
Errorf
(
"polling should be on by default"
)
t
.
Errorf
(
"polling should be on by default"
)
...
@@ -307,7 +316,8 @@ func TestPolling(t *testing.T) {
...
@@ -307,7 +316,8 @@ func TestPolling(t *testing.T) {
}))
}))
auth
:=
AuthInfo
{
User
:
"user"
,
Password
:
"pass"
}
auth
:=
AuthInfo
{
User
:
"user"
,
Password
:
"pass"
}
c
:=
NewOrDie
(
testServer
.
URL
,
"v1beta1"
,
&
auth
)
ctx
:=
api
.
NewContext
()
c
:=
NewOrDie
(
ctx
,
testServer
.
URL
,
"v1beta1"
,
&
auth
)
trials
:=
[]
func
(){
trials
:=
[]
func
(){
func
()
{
func
()
{
...
@@ -411,7 +421,8 @@ func TestWatch(t *testing.T) {
...
@@ -411,7 +421,8 @@ func TestWatch(t *testing.T) {
}
}
}))
}))
s
,
err
:=
New
(
testServer
.
URL
,
"v1beta1"
,
&
auth
)
ctx
:=
api
.
NewContext
()
s
,
err
:=
New
(
ctx
,
testServer
.
URL
,
"v1beta1"
,
&
auth
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
}
}
...
...
pkg/controller/replication_controller_test.go
View file @
02e1a2e7
...
@@ -117,7 +117,7 @@ func TestSyncReplicationControllerDoesNothing(t *testing.T) {
...
@@ -117,7 +117,7 @@ func TestSyncReplicationControllerDoesNothing(t *testing.T) {
ResponseBody
:
string
(
body
),
ResponseBody
:
string
(
body
),
}
}
testServer
:=
httptest
.
NewTLSServer
(
&
fakeHandler
)
testServer
:=
httptest
.
NewTLSServer
(
&
fakeHandler
)
client
:=
client
.
NewOrDie
(
testServer
.
URL
,
"v1beta1"
,
nil
)
client
:=
client
.
NewOrDie
(
api
.
NewContext
(),
testServer
.
URL
,
"v1beta1"
,
nil
)
fakePodControl
:=
FakePodControl
{}
fakePodControl
:=
FakePodControl
{}
...
@@ -137,7 +137,7 @@ func TestSyncReplicationControllerDeletes(t *testing.T) {
...
@@ -137,7 +137,7 @@ func TestSyncReplicationControllerDeletes(t *testing.T) {
ResponseBody
:
string
(
body
),
ResponseBody
:
string
(
body
),
}
}
testServer
:=
httptest
.
NewTLSServer
(
&
fakeHandler
)
testServer
:=
httptest
.
NewTLSServer
(
&
fakeHandler
)
client
:=
client
.
NewOrDie
(
testServer
.
URL
,
"v1beta1"
,
nil
)
client
:=
client
.
NewOrDie
(
api
.
NewContext
(),
testServer
.
URL
,
"v1beta1"
,
nil
)
fakePodControl
:=
FakePodControl
{}
fakePodControl
:=
FakePodControl
{}
...
@@ -157,7 +157,7 @@ func TestSyncReplicationControllerCreates(t *testing.T) {
...
@@ -157,7 +157,7 @@ func TestSyncReplicationControllerCreates(t *testing.T) {
ResponseBody
:
string
(
body
),
ResponseBody
:
string
(
body
),
}
}
testServer
:=
httptest
.
NewTLSServer
(
&
fakeHandler
)
testServer
:=
httptest
.
NewTLSServer
(
&
fakeHandler
)
client
:=
client
.
NewOrDie
(
testServer
.
URL
,
"v1beta1"
,
nil
)
client
:=
client
.
NewOrDie
(
api
.
NewContext
(),
testServer
.
URL
,
"v1beta1"
,
nil
)
fakePodControl
:=
FakePodControl
{}
fakePodControl
:=
FakePodControl
{}
...
@@ -177,7 +177,7 @@ func TestCreateReplica(t *testing.T) {
...
@@ -177,7 +177,7 @@ func TestCreateReplica(t *testing.T) {
ResponseBody
:
string
(
body
),
ResponseBody
:
string
(
body
),
}
}
testServer
:=
httptest
.
NewTLSServer
(
&
fakeHandler
)
testServer
:=
httptest
.
NewTLSServer
(
&
fakeHandler
)
client
:=
client
.
NewOrDie
(
testServer
.
URL
,
"v1beta1"
,
nil
)
client
:=
client
.
NewOrDie
(
api
.
NewContext
(),
testServer
.
URL
,
"v1beta1"
,
nil
)
podControl
:=
RealPodControl
{
podControl
:=
RealPodControl
{
kubeClient
:
client
,
kubeClient
:
client
,
...
@@ -310,7 +310,7 @@ func TestSynchonize(t *testing.T) {
...
@@ -310,7 +310,7 @@ func TestSynchonize(t *testing.T) {
t
.
Errorf
(
"Unexpected request for %v"
,
req
.
RequestURI
)
t
.
Errorf
(
"Unexpected request for %v"
,
req
.
RequestURI
)
})
})
testServer
:=
httptest
.
NewServer
(
mux
)
testServer
:=
httptest
.
NewServer
(
mux
)
client
:=
client
.
NewOrDie
(
testServer
.
URL
,
"v1beta1"
,
nil
)
client
:=
client
.
NewOrDie
(
api
.
NewContext
(),
testServer
.
URL
,
"v1beta1"
,
nil
)
manager
:=
NewReplicationManager
(
client
)
manager
:=
NewReplicationManager
(
client
)
fakePodControl
:=
FakePodControl
{}
fakePodControl
:=
FakePodControl
{}
manager
.
podControl
=
&
fakePodControl
manager
.
podControl
=
&
fakePodControl
...
...
pkg/service/endpoints_controller_test.go
View file @
02e1a2e7
...
@@ -159,7 +159,7 @@ func TestSyncEndpointsEmpty(t *testing.T) {
...
@@ -159,7 +159,7 @@ func TestSyncEndpointsEmpty(t *testing.T) {
serverResponse
{
http
.
StatusOK
,
newPodList
(
0
)},
serverResponse
{
http
.
StatusOK
,
newPodList
(
0
)},
serverResponse
{
http
.
StatusOK
,
api
.
ServiceList
{}},
serverResponse
{
http
.
StatusOK
,
api
.
ServiceList
{}},
serverResponse
{
http
.
StatusOK
,
api
.
Endpoints
{}})
serverResponse
{
http
.
StatusOK
,
api
.
Endpoints
{}})
client
:=
client
.
NewOrDie
(
testServer
.
URL
,
"v1beta1"
,
nil
)
client
:=
client
.
NewOrDie
(
api
.
NewContext
(),
testServer
.
URL
,
"v1beta1"
,
nil
)
serviceRegistry
:=
registrytest
.
ServiceRegistry
{}
serviceRegistry
:=
registrytest
.
ServiceRegistry
{}
endpoints
:=
NewEndpointController
(
&
serviceRegistry
,
client
)
endpoints
:=
NewEndpointController
(
&
serviceRegistry
,
client
)
if
err
:=
endpoints
.
SyncServiceEndpoints
();
err
!=
nil
{
if
err
:=
endpoints
.
SyncServiceEndpoints
();
err
!=
nil
{
...
@@ -172,7 +172,7 @@ func TestSyncEndpointsError(t *testing.T) {
...
@@ -172,7 +172,7 @@ func TestSyncEndpointsError(t *testing.T) {
serverResponse
{
http
.
StatusOK
,
newPodList
(
0
)},
serverResponse
{
http
.
StatusOK
,
newPodList
(
0
)},
serverResponse
{
http
.
StatusInternalServerError
,
api
.
ServiceList
{}},
serverResponse
{
http
.
StatusInternalServerError
,
api
.
ServiceList
{}},
serverResponse
{
http
.
StatusOK
,
api
.
Endpoints
{}})
serverResponse
{
http
.
StatusOK
,
api
.
Endpoints
{}})
client
:=
client
.
NewOrDie
(
testServer
.
URL
,
"v1beta1"
,
nil
)
client
:=
client
.
NewOrDie
(
api
.
NewContext
(),
testServer
.
URL
,
"v1beta1"
,
nil
)
serviceRegistry
:=
registrytest
.
ServiceRegistry
{
serviceRegistry
:=
registrytest
.
ServiceRegistry
{
Err
:
fmt
.
Errorf
(
"test error"
),
Err
:
fmt
.
Errorf
(
"test error"
),
}
}
...
@@ -203,7 +203,7 @@ func TestSyncEndpointsItemsPreexisting(t *testing.T) {
...
@@ -203,7 +203,7 @@ func TestSyncEndpointsItemsPreexisting(t *testing.T) {
},
},
Endpoints
:
[]
string
{
"6.7.8.9:1000"
},
Endpoints
:
[]
string
{
"6.7.8.9:1000"
},
}})
}})
client
:=
client
.
NewOrDie
(
testServer
.
URL
,
"v1beta1"
,
nil
)
client
:=
client
.
NewOrDie
(
api
.
NewContext
(),
testServer
.
URL
,
"v1beta1"
,
nil
)
serviceRegistry
:=
registrytest
.
ServiceRegistry
{}
serviceRegistry
:=
registrytest
.
ServiceRegistry
{}
endpoints
:=
NewEndpointController
(
&
serviceRegistry
,
client
)
endpoints
:=
NewEndpointController
(
&
serviceRegistry
,
client
)
if
err
:=
endpoints
.
SyncServiceEndpoints
();
err
!=
nil
{
if
err
:=
endpoints
.
SyncServiceEndpoints
();
err
!=
nil
{
...
@@ -239,7 +239,7 @@ func TestSyncEndpointsItemsPreexistingIdentical(t *testing.T) {
...
@@ -239,7 +239,7 @@ func TestSyncEndpointsItemsPreexistingIdentical(t *testing.T) {
},
},
Endpoints
:
[]
string
{
"1.2.3.4:8080"
},
Endpoints
:
[]
string
{
"1.2.3.4:8080"
},
}})
}})
client
:=
client
.
NewOrDie
(
testServer
.
URL
,
"v1beta1"
,
nil
)
client
:=
client
.
NewOrDie
(
api
.
NewContext
(),
testServer
.
URL
,
"v1beta1"
,
nil
)
serviceRegistry
:=
registrytest
.
ServiceRegistry
{}
serviceRegistry
:=
registrytest
.
ServiceRegistry
{}
endpoints
:=
NewEndpointController
(
&
serviceRegistry
,
client
)
endpoints
:=
NewEndpointController
(
&
serviceRegistry
,
client
)
if
err
:=
endpoints
.
SyncServiceEndpoints
();
err
!=
nil
{
if
err
:=
endpoints
.
SyncServiceEndpoints
();
err
!=
nil
{
...
@@ -263,7 +263,7 @@ func TestSyncEndpointsItems(t *testing.T) {
...
@@ -263,7 +263,7 @@ func TestSyncEndpointsItems(t *testing.T) {
serverResponse
{
http
.
StatusOK
,
newPodList
(
1
)},
serverResponse
{
http
.
StatusOK
,
newPodList
(
1
)},
serverResponse
{
http
.
StatusOK
,
serviceList
},
serverResponse
{
http
.
StatusOK
,
serviceList
},
serverResponse
{
http
.
StatusOK
,
api
.
Endpoints
{}})
serverResponse
{
http
.
StatusOK
,
api
.
Endpoints
{}})
client
:=
client
.
NewOrDie
(
testServer
.
URL
,
"v1beta1"
,
nil
)
client
:=
client
.
NewOrDie
(
api
.
NewContext
(),
testServer
.
URL
,
"v1beta1"
,
nil
)
serviceRegistry
:=
registrytest
.
ServiceRegistry
{}
serviceRegistry
:=
registrytest
.
ServiceRegistry
{}
endpoints
:=
NewEndpointController
(
&
serviceRegistry
,
client
)
endpoints
:=
NewEndpointController
(
&
serviceRegistry
,
client
)
if
err
:=
endpoints
.
SyncServiceEndpoints
();
err
!=
nil
{
if
err
:=
endpoints
.
SyncServiceEndpoints
();
err
!=
nil
{
...
@@ -292,7 +292,7 @@ func TestSyncEndpointsPodError(t *testing.T) {
...
@@ -292,7 +292,7 @@ func TestSyncEndpointsPodError(t *testing.T) {
serverResponse
{
http
.
StatusInternalServerError
,
api
.
PodList
{}},
serverResponse
{
http
.
StatusInternalServerError
,
api
.
PodList
{}},
serverResponse
{
http
.
StatusOK
,
serviceList
},
serverResponse
{
http
.
StatusOK
,
serviceList
},
serverResponse
{
http
.
StatusOK
,
api
.
Endpoints
{}})
serverResponse
{
http
.
StatusOK
,
api
.
Endpoints
{}})
client
:=
client
.
NewOrDie
(
testServer
.
URL
,
"v1beta1"
,
nil
)
client
:=
client
.
NewOrDie
(
api
.
NewContext
(),
testServer
.
URL
,
"v1beta1"
,
nil
)
serviceRegistry
:=
registrytest
.
ServiceRegistry
{
serviceRegistry
:=
registrytest
.
ServiceRegistry
{
List
:
api
.
ServiceList
{
List
:
api
.
ServiceList
{
Items
:
[]
api
.
Service
{
Items
:
[]
api
.
Service
{
...
...
plugin/pkg/scheduler/factory/factory_test.go
View file @
02e1a2e7
...
@@ -39,7 +39,7 @@ func TestCreate(t *testing.T) {
...
@@ -39,7 +39,7 @@ func TestCreate(t *testing.T) {
T
:
t
,
T
:
t
,
}
}
server
:=
httptest
.
NewServer
(
&
handler
)
server
:=
httptest
.
NewServer
(
&
handler
)
client
:=
client
.
NewOrDie
(
server
.
URL
,
""
,
nil
)
client
:=
client
.
NewOrDie
(
api
.
NewContext
(),
server
.
URL
,
""
,
nil
)
factory
:=
ConfigFactory
{
client
}
factory
:=
ConfigFactory
{
client
}
factory
.
Create
()
factory
.
Create
()
}
}
...
@@ -74,7 +74,7 @@ func TestCreateLists(t *testing.T) {
...
@@ -74,7 +74,7 @@ func TestCreateLists(t *testing.T) {
T
:
t
,
T
:
t
,
}
}
server
:=
httptest
.
NewServer
(
&
handler
)
server
:=
httptest
.
NewServer
(
&
handler
)
factory
.
Client
=
client
.
NewOrDie
(
server
.
URL
,
latest
.
OldestVersion
,
nil
)
factory
.
Client
=
client
.
NewOrDie
(
api
.
NewContext
(),
server
.
URL
,
latest
.
OldestVersion
,
nil
)
// This test merely tests that the correct request is made.
// This test merely tests that the correct request is made.
item
.
factory
()
.
List
()
item
.
factory
()
.
List
()
handler
.
ValidateRequest
(
t
,
item
.
location
,
"GET"
,
nil
)
handler
.
ValidateRequest
(
t
,
item
.
location
,
"GET"
,
nil
)
...
@@ -127,7 +127,7 @@ func TestCreateWatches(t *testing.T) {
...
@@ -127,7 +127,7 @@ func TestCreateWatches(t *testing.T) {
T
:
t
,
T
:
t
,
}
}
server
:=
httptest
.
NewServer
(
&
handler
)
server
:=
httptest
.
NewServer
(
&
handler
)
factory
.
Client
=
client
.
NewOrDie
(
server
.
URL
,
"v1beta1"
,
nil
)
factory
.
Client
=
client
.
NewOrDie
(
api
.
NewContext
(),
server
.
URL
,
"v1beta1"
,
nil
)
// This test merely tests that the correct request is made.
// This test merely tests that the correct request is made.
item
.
factory
()
.
Watch
(
item
.
rv
)
item
.
factory
()
.
Watch
(
item
.
rv
)
handler
.
ValidateRequest
(
t
,
item
.
location
,
"GET"
,
nil
)
handler
.
ValidateRequest
(
t
,
item
.
location
,
"GET"
,
nil
)
...
@@ -157,7 +157,7 @@ func TestPollMinions(t *testing.T) {
...
@@ -157,7 +157,7 @@ func TestPollMinions(t *testing.T) {
// FakeHandler musn't be sent requests other than the one you want to test.
// FakeHandler musn't be sent requests other than the one you want to test.
mux
.
Handle
(
"/api/v1beta1/minions"
,
&
handler
)
mux
.
Handle
(
"/api/v1beta1/minions"
,
&
handler
)
server
:=
httptest
.
NewServer
(
mux
)
server
:=
httptest
.
NewServer
(
mux
)
client
:=
client
.
NewOrDie
(
server
.
URL
,
"v1beta1"
,
nil
)
client
:=
client
.
NewOrDie
(
api
.
NewContext
(),
server
.
URL
,
"v1beta1"
,
nil
)
cf
:=
ConfigFactory
{
client
}
cf
:=
ConfigFactory
{
client
}
ce
,
err
:=
cf
.
pollMinions
()
ce
,
err
:=
cf
.
pollMinions
()
...
@@ -184,7 +184,7 @@ func TestDefaultErrorFunc(t *testing.T) {
...
@@ -184,7 +184,7 @@ func TestDefaultErrorFunc(t *testing.T) {
// FakeHandler musn't be sent requests other than the one you want to test.
// FakeHandler musn't be sent requests other than the one you want to test.
mux
.
Handle
(
"/api/v1beta1/pods/foo"
,
&
handler
)
mux
.
Handle
(
"/api/v1beta1/pods/foo"
,
&
handler
)
server
:=
httptest
.
NewServer
(
mux
)
server
:=
httptest
.
NewServer
(
mux
)
factory
:=
ConfigFactory
{
client
.
NewOrDie
(
server
.
URL
,
""
,
nil
)}
factory
:=
ConfigFactory
{
client
.
NewOrDie
(
api
.
NewContext
(),
server
.
URL
,
""
,
nil
)}
queue
:=
cache
.
NewFIFO
()
queue
:=
cache
.
NewFIFO
()
errFunc
:=
factory
.
makeDefaultErrorFunc
(
queue
)
errFunc
:=
factory
.
makeDefaultErrorFunc
(
queue
)
...
@@ -289,7 +289,7 @@ func TestBind(t *testing.T) {
...
@@ -289,7 +289,7 @@ func TestBind(t *testing.T) {
T
:
t
,
T
:
t
,
}
}
server
:=
httptest
.
NewServer
(
&
handler
)
server
:=
httptest
.
NewServer
(
&
handler
)
client
:=
client
.
NewOrDie
(
server
.
URL
,
""
,
nil
)
client
:=
client
.
NewOrDie
(
api
.
NewContext
(),
server
.
URL
,
""
,
nil
)
b
:=
binder
{
client
}
b
:=
binder
{
client
}
if
err
:=
b
.
Bind
(
item
.
binding
);
err
!=
nil
{
if
err
:=
b
.
Bind
(
item
.
binding
);
err
!=
nil
{
...
...
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