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
acefdc9d
Commit
acefdc9d
authored
Aug 07, 2015
by
Jerzy Szczepkowski
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #12355 from derekwaynecarr/test_events_ns
Event test client may or may not be namespaced
parents
14cfc430
72be2443
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
9 deletions
+38
-9
fake_events.go
pkg/client/testclient/fake_events.go
+37
-8
testclient.go
pkg/client/testclient/testclient.go
+1
-1
No files found.
pkg/client/testclient/fake_events.go
View file @
acefdc9d
...
...
@@ -27,12 +27,17 @@ import (
// FakeEvents implements EventInterface. Meant to be embedded into a struct to get a default
// implementation. This makes faking out just the method you want to test easier.
type
FakeEvents
struct
{
Fake
*
Fake
Fake
*
Fake
Namespace
string
}
// Get returns the given event, or an error.
func
(
c
*
FakeEvents
)
Get
(
name
string
)
(
*
api
.
Event
,
error
)
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
NewRootGetAction
(
"events"
,
name
),
&
api
.
Event
{})
action
:=
NewRootGetAction
(
"events"
,
name
)
if
c
.
Namespace
!=
""
{
action
=
NewGetAction
(
"events"
,
c
.
Namespace
,
name
)
}
obj
,
err
:=
c
.
Fake
.
Invokes
(
action
,
&
api
.
Event
{})
if
obj
==
nil
{
return
nil
,
err
}
...
...
@@ -42,7 +47,11 @@ func (c *FakeEvents) Get(name string) (*api.Event, error) {
// List returns a list of events matching the selectors.
func
(
c
*
FakeEvents
)
List
(
label
labels
.
Selector
,
field
fields
.
Selector
)
(
*
api
.
EventList
,
error
)
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
NewRootListAction
(
"events"
,
label
,
field
),
&
api
.
EventList
{})
action
:=
NewRootListAction
(
"events"
,
label
,
field
)
if
c
.
Namespace
!=
""
{
action
=
NewListAction
(
"events"
,
c
.
Namespace
,
label
,
field
)
}
obj
,
err
:=
c
.
Fake
.
Invokes
(
action
,
&
api
.
EventList
{})
if
obj
==
nil
{
return
nil
,
err
}
...
...
@@ -52,7 +61,11 @@ func (c *FakeEvents) List(label labels.Selector, field fields.Selector) (*api.Ev
// Create makes a new event. Returns the copy of the event the server returns, or an error.
func
(
c
*
FakeEvents
)
Create
(
event
*
api
.
Event
)
(
*
api
.
Event
,
error
)
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
NewRootCreateAction
(
"events"
,
event
),
event
)
action
:=
NewRootCreateAction
(
"events"
,
event
)
if
c
.
Namespace
!=
""
{
action
=
NewCreateAction
(
"events"
,
c
.
Namespace
,
event
)
}
obj
,
err
:=
c
.
Fake
.
Invokes
(
action
,
event
)
if
obj
==
nil
{
return
nil
,
err
}
...
...
@@ -62,7 +75,11 @@ func (c *FakeEvents) Create(event *api.Event) (*api.Event, error) {
// Update replaces an existing event. Returns the copy of the event the server returns, or an error.
func
(
c
*
FakeEvents
)
Update
(
event
*
api
.
Event
)
(
*
api
.
Event
,
error
)
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
NewRootUpdateAction
(
"events"
,
event
),
event
)
action
:=
NewRootUpdateAction
(
"events"
,
event
)
if
c
.
Namespace
!=
""
{
action
=
NewUpdateAction
(
"events"
,
c
.
Namespace
,
event
)
}
obj
,
err
:=
c
.
Fake
.
Invokes
(
action
,
event
)
if
obj
==
nil
{
return
nil
,
err
}
...
...
@@ -71,19 +88,31 @@ func (c *FakeEvents) Update(event *api.Event) (*api.Event, error) {
}
func
(
c
*
FakeEvents
)
Delete
(
name
string
)
error
{
_
,
err
:=
c
.
Fake
.
Invokes
(
NewRootDeleteAction
(
"events"
,
name
),
&
api
.
Event
{})
action
:=
NewRootDeleteAction
(
"events"
,
name
)
if
c
.
Namespace
!=
""
{
action
=
NewDeleteAction
(
"events"
,
c
.
Namespace
,
name
)
}
_
,
err
:=
c
.
Fake
.
Invokes
(
action
,
&
api
.
Event
{})
return
err
}
// Watch starts watching for events matching the given selectors.
func
(
c
*
FakeEvents
)
Watch
(
label
labels
.
Selector
,
field
fields
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
{
c
.
Fake
.
Invokes
(
NewRootWatchAction
(
"events"
,
label
,
field
,
resourceVersion
),
nil
)
action
:=
NewRootWatchAction
(
"events"
,
label
,
field
,
resourceVersion
)
if
c
.
Namespace
!=
""
{
action
=
NewWatchAction
(
"events"
,
c
.
Namespace
,
label
,
field
,
resourceVersion
)
}
c
.
Fake
.
Invokes
(
action
,
nil
)
return
c
.
Fake
.
Watch
,
c
.
Fake
.
Err
()
}
// Search returns a list of events matching the specified object.
func
(
c
*
FakeEvents
)
Search
(
objOrRef
runtime
.
Object
)
(
*
api
.
EventList
,
error
)
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
NewRootListAction
(
"events"
,
nil
,
nil
),
&
api
.
EventList
{})
action
:=
NewRootListAction
(
"events"
,
nil
,
nil
)
if
c
.
Namespace
!=
""
{
action
=
NewListAction
(
"events"
,
c
.
Namespace
,
nil
,
nil
)
}
obj
,
err
:=
c
.
Fake
.
Invokes
(
action
,
&
api
.
EventList
{})
if
obj
==
nil
{
return
nil
,
err
}
...
...
pkg/client/testclient/testclient.go
View file @
acefdc9d
...
...
@@ -119,7 +119,7 @@ func (c *Fake) Nodes() client.NodeInterface {
}
func
(
c
*
Fake
)
Events
(
namespace
string
)
client
.
EventInterface
{
return
&
FakeEvents
{
Fake
:
c
}
return
&
FakeEvents
{
Fake
:
c
,
Namespace
:
namespace
}
}
func
(
c
*
Fake
)
Endpoints
(
namespace
string
)
client
.
EndpointsInterface
{
...
...
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