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
ad47b2d2
Commit
ad47b2d2
authored
May 21, 2015
by
Dawn Chen
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #8483 from liggitt/etcd_test
Update generic etcd tests for cluster-scoped objects
parents
9f4fb35c
a6401fa4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
146 additions
and
66 deletions
+146
-66
resttest.go
pkg/api/rest/resttest/resttest.go
+96
-29
etcd_test.go
pkg/registry/minion/etcd/etcd_test.go
+4
-4
etcd_test.go
pkg/registry/namespace/etcd/etcd_test.go
+12
-12
etcd_test.go
pkg/registry/persistentvolume/etcd/etcd_test.go
+11
-11
etcd_test.go
pkg/registry/podtemplate/etcd/etcd_test.go
+7
-2
etcd_test.go
pkg/registry/secret/etcd/etcd_test.go
+8
-4
etcd_test.go
pkg/registry/serviceaccount/etcd/etcd_test.go
+8
-4
No files found.
pkg/api/rest/resttest/resttest.go
View file @
ad47b2d2
This diff is collapsed.
Click to expand it.
pkg/registry/minion/etcd/etcd_test.go
View file @
ad47b2d2
...
@@ -88,9 +88,9 @@ func validChangedNode() *api.Node {
...
@@ -88,9 +88,9 @@ func validChangedNode() *api.Node {
func
TestCreate
(
t
*
testing
.
T
)
{
func
TestCreate
(
t
*
testing
.
T
)
{
storage
,
fakeEtcdClient
:=
newStorage
(
t
)
storage
,
fakeEtcdClient
:=
newStorage
(
t
)
test
:=
resttest
.
New
(
t
,
storage
,
fakeEtcdClient
.
SetError
)
test
:=
resttest
.
New
(
t
,
storage
,
fakeEtcdClient
.
SetError
)
.
ClusterScope
()
node
:=
validNewNode
()
node
:=
validNewNode
()
node
.
ObjectMeta
=
api
.
ObjectMeta
{}
node
.
ObjectMeta
=
api
.
ObjectMeta
{
GenerateName
:
"foo"
}
test
.
TestCreate
(
test
.
TestCreate
(
// valid
// valid
node
,
node
,
...
@@ -102,9 +102,9 @@ func TestCreate(t *testing.T) {
...
@@ -102,9 +102,9 @@ func TestCreate(t *testing.T) {
}
}
func
TestDelete
(
t
*
testing
.
T
)
{
func
TestDelete
(
t
*
testing
.
T
)
{
ctx
:=
api
.
New
Default
Context
()
ctx
:=
api
.
NewContext
()
storage
,
fakeEtcdClient
:=
newStorage
(
t
)
storage
,
fakeEtcdClient
:=
newStorage
(
t
)
test
:=
resttest
.
New
(
t
,
storage
,
fakeEtcdClient
.
SetError
)
test
:=
resttest
.
New
(
t
,
storage
,
fakeEtcdClient
.
SetError
)
.
ClusterScope
()
node
:=
validChangedNode
()
node
:=
validChangedNode
()
key
,
_
:=
storage
.
KeyFunc
(
ctx
,
node
.
Name
)
key
,
_
:=
storage
.
KeyFunc
(
ctx
,
node
.
Name
)
...
...
pkg/registry/namespace/etcd/etcd_test.go
View file @
ad47b2d2
...
@@ -71,15 +71,15 @@ func TestStorage(t *testing.T) {
...
@@ -71,15 +71,15 @@ func TestStorage(t *testing.T) {
func
TestCreate
(
t
*
testing
.
T
)
{
func
TestCreate
(
t
*
testing
.
T
)
{
fakeEtcdClient
,
helper
:=
newHelper
(
t
)
fakeEtcdClient
,
helper
:=
newHelper
(
t
)
storage
,
_
,
_
:=
NewStorage
(
helper
)
storage
,
_
,
_
:=
NewStorage
(
helper
)
test
:=
resttest
.
New
(
t
,
storage
,
fakeEtcdClient
.
SetError
)
test
:=
resttest
.
New
(
t
,
storage
,
fakeEtcdClient
.
SetError
)
.
ClusterScope
()
namespace
:=
validNewNamespace
()
namespace
:=
validNewNamespace
()
namespace
.
ObjectMeta
=
api
.
ObjectMeta
{}
namespace
.
ObjectMeta
=
api
.
ObjectMeta
{
GenerateName
:
"foo"
}
test
.
TestCreate
(
test
.
TestCreate
(
// valid
// valid
namespace
,
namespace
,
// invalid
// invalid
&
api
.
Namespace
{
&
api
.
Namespace
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
space
:
"nop
e"
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"bad valu
e"
},
},
},
)
)
}
}
...
@@ -97,13 +97,13 @@ func TestCreateSetsFields(t *testing.T) {
...
@@ -97,13 +97,13 @@ func TestCreateSetsFields(t *testing.T) {
fakeEtcdClient
,
helper
:=
newHelper
(
t
)
fakeEtcdClient
,
helper
:=
newHelper
(
t
)
storage
,
_
,
_
:=
NewStorage
(
helper
)
storage
,
_
,
_
:=
NewStorage
(
helper
)
namespace
:=
validNewNamespace
()
namespace
:=
validNewNamespace
()
_
,
err
:=
storage
.
Create
(
api
.
New
Default
Context
(),
namespace
)
_
,
err
:=
storage
.
Create
(
api
.
NewContext
(),
namespace
)
if
err
!=
fakeEtcdClient
.
Err
{
if
err
!=
fakeEtcdClient
.
Err
{
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
}
}
actual
:=
&
api
.
Namespace
{}
actual
:=
&
api
.
Namespace
{}
ctx
:=
api
.
New
Default
Context
()
ctx
:=
api
.
NewContext
()
key
,
err
:=
storage
.
Etcd
.
KeyFunc
(
ctx
,
"foo"
)
key
,
err
:=
storage
.
Etcd
.
KeyFunc
(
ctx
,
"foo"
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"unexpected key error: %v"
,
err
)
t
.
Fatalf
(
"unexpected key error: %v"
,
err
)
...
@@ -166,7 +166,7 @@ func TestListNamespaceList(t *testing.T) {
...
@@ -166,7 +166,7 @@ func TestListNamespaceList(t *testing.T) {
},
},
}
}
storage
,
_
,
_
:=
NewStorage
(
helper
)
storage
,
_
,
_
:=
NewStorage
(
helper
)
namespacesObj
,
err
:=
storage
.
List
(
api
.
New
Default
Context
(),
labels
.
Everything
(),
fields
.
Everything
())
namespacesObj
,
err
:=
storage
.
List
(
api
.
NewContext
(),
labels
.
Everything
(),
fields
.
Everything
())
namespaces
:=
namespacesObj
.
(
*
api
.
NamespaceList
)
namespaces
:=
namespacesObj
.
(
*
api
.
NamespaceList
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
...
@@ -214,7 +214,7 @@ func TestListNamespaceListSelection(t *testing.T) {
...
@@ -214,7 +214,7 @@ func TestListNamespaceListSelection(t *testing.T) {
},
},
}
}
storage
,
_
,
_
:=
NewStorage
(
helper
)
storage
,
_
,
_
:=
NewStorage
(
helper
)
ctx
:=
api
.
New
Default
Context
()
ctx
:=
api
.
NewContext
()
table
:=
[]
struct
{
table
:=
[]
struct
{
label
,
field
string
label
,
field
string
expectedIDs
util
.
StringSet
expectedIDs
util
.
StringSet
...
@@ -285,7 +285,7 @@ func TestGet(t *testing.T) {
...
@@ -285,7 +285,7 @@ func TestGet(t *testing.T) {
expect
:=
validNewNamespace
()
expect
:=
validNewNamespace
()
expect
.
Status
.
Phase
=
api
.
NamespaceActive
expect
.
Status
.
Phase
=
api
.
NamespaceActive
storage
,
fakeEtcdClient
,
_
:=
newStorage
(
t
)
storage
,
fakeEtcdClient
,
_
:=
newStorage
(
t
)
ctx
:=
api
.
New
Default
Context
()
ctx
:=
api
.
NewContext
()
key
,
err
:=
storage
.
Etcd
.
KeyFunc
(
ctx
,
"foo"
)
key
,
err
:=
storage
.
Etcd
.
KeyFunc
(
ctx
,
"foo"
)
key
=
etcdtest
.
AddPrefix
(
key
)
key
=
etcdtest
.
AddPrefix
(
key
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -314,7 +314,7 @@ func TestDeleteNamespace(t *testing.T) {
...
@@ -314,7 +314,7 @@ func TestDeleteNamespace(t *testing.T) {
fakeEtcdClient
,
helper
:=
newHelper
(
t
)
fakeEtcdClient
,
helper
:=
newHelper
(
t
)
fakeEtcdClient
.
ChangeIndex
=
1
fakeEtcdClient
.
ChangeIndex
=
1
storage
,
_
,
_
:=
NewStorage
(
helper
)
storage
,
_
,
_
:=
NewStorage
(
helper
)
ctx
:=
api
.
New
Default
Context
()
ctx
:=
api
.
NewContext
()
key
,
err
:=
storage
.
Etcd
.
KeyFunc
(
ctx
,
"foo"
)
key
,
err
:=
storage
.
Etcd
.
KeyFunc
(
ctx
,
"foo"
)
key
=
etcdtest
.
AddPrefix
(
key
)
key
=
etcdtest
.
AddPrefix
(
key
)
fakeEtcdClient
.
Data
[
key
]
=
tools
.
EtcdResponseWithError
{
fakeEtcdClient
.
Data
[
key
]
=
tools
.
EtcdResponseWithError
{
...
@@ -331,7 +331,7 @@ func TestDeleteNamespace(t *testing.T) {
...
@@ -331,7 +331,7 @@ func TestDeleteNamespace(t *testing.T) {
},
},
},
},
}
}
_
,
err
=
storage
.
Delete
(
api
.
New
Default
Context
(),
"foo"
,
nil
)
_
,
err
=
storage
.
Delete
(
api
.
NewContext
(),
"foo"
,
nil
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
...
@@ -362,7 +362,7 @@ func TestDeleteNamespaceWithIncompleteFinalizers(t *testing.T) {
...
@@ -362,7 +362,7 @@ func TestDeleteNamespaceWithIncompleteFinalizers(t *testing.T) {
},
},
}
}
storage
,
_
,
_
:=
NewStorage
(
helper
)
storage
,
_
,
_
:=
NewStorage
(
helper
)
_
,
err
:=
storage
.
Delete
(
api
.
New
Default
Context
(),
"foo"
,
nil
)
_
,
err
:=
storage
.
Delete
(
api
.
NewContext
(),
"foo"
,
nil
)
if
err
==
nil
{
if
err
==
nil
{
t
.
Fatalf
(
"expected error: %v"
,
err
)
t
.
Fatalf
(
"expected error: %v"
,
err
)
}
}
...
@@ -392,7 +392,7 @@ func TestDeleteNamespaceWithCompleteFinalizers(t *testing.T) {
...
@@ -392,7 +392,7 @@ func TestDeleteNamespaceWithCompleteFinalizers(t *testing.T) {
},
},
}
}
storage
,
_
,
_
:=
NewStorage
(
helper
)
storage
,
_
,
_
:=
NewStorage
(
helper
)
_
,
err
:=
storage
.
Delete
(
api
.
New
Default
Context
(),
"foo"
,
nil
)
_
,
err
:=
storage
.
Delete
(
api
.
NewContext
(),
"foo"
,
nil
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
}
}
...
...
pkg/registry/persistentvolume/etcd/etcd_test.go
View file @
ad47b2d2
...
@@ -75,9 +75,9 @@ func validChangedPersistentVolume() *api.PersistentVolume {
...
@@ -75,9 +75,9 @@ func validChangedPersistentVolume() *api.PersistentVolume {
func
TestCreate
(
t
*
testing
.
T
)
{
func
TestCreate
(
t
*
testing
.
T
)
{
storage
,
_
,
fakeEtcdClient
,
_
:=
newStorage
(
t
)
storage
,
_
,
fakeEtcdClient
,
_
:=
newStorage
(
t
)
test
:=
resttest
.
New
(
t
,
storage
,
fakeEtcdClient
.
SetError
)
test
:=
resttest
.
New
(
t
,
storage
,
fakeEtcdClient
.
SetError
)
.
ClusterScope
()
pv
:=
validNewPersistentVolume
(
"foo"
)
pv
:=
validNewPersistentVolume
(
"foo"
)
pv
.
ObjectMeta
=
api
.
ObjectMeta
{}
pv
.
ObjectMeta
=
api
.
ObjectMeta
{
GenerateName
:
"foo"
}
test
.
TestCreate
(
test
.
TestCreate
(
// valid
// valid
pv
,
pv
,
...
@@ -89,9 +89,9 @@ func TestCreate(t *testing.T) {
...
@@ -89,9 +89,9 @@ func TestCreate(t *testing.T) {
}
}
func
TestDelete
(
t
*
testing
.
T
)
{
func
TestDelete
(
t
*
testing
.
T
)
{
ctx
:=
api
.
New
Default
Context
()
ctx
:=
api
.
NewContext
()
storage
,
_
,
fakeEtcdClient
,
_
:=
newStorage
(
t
)
storage
,
_
,
fakeEtcdClient
,
_
:=
newStorage
(
t
)
test
:=
resttest
.
New
(
t
,
storage
,
fakeEtcdClient
.
SetError
)
test
:=
resttest
.
New
(
t
,
storage
,
fakeEtcdClient
.
SetError
)
.
ClusterScope
()
pv
:=
validChangedPersistentVolume
()
pv
:=
validChangedPersistentVolume
()
key
,
_
:=
storage
.
KeyFunc
(
ctx
,
pv
.
Name
)
key
,
_
:=
storage
.
KeyFunc
(
ctx
,
pv
.
Name
)
...
@@ -117,7 +117,7 @@ func TestDelete(t *testing.T) {
...
@@ -117,7 +117,7 @@ func TestDelete(t *testing.T) {
}
}
func
TestEtcdListPersistentVolumes
(
t
*
testing
.
T
)
{
func
TestEtcdListPersistentVolumes
(
t
*
testing
.
T
)
{
ctx
:=
api
.
New
Default
Context
()
ctx
:=
api
.
NewContext
()
storage
,
_
,
fakeClient
,
_
:=
newStorage
(
t
)
storage
,
_
,
fakeClient
,
_
:=
newStorage
(
t
)
key
:=
storage
.
KeyRootFunc
(
ctx
)
key
:=
storage
.
KeyRootFunc
(
ctx
)
key
=
etcdtest
.
AddPrefix
(
key
)
key
=
etcdtest
.
AddPrefix
(
key
)
...
@@ -149,7 +149,7 @@ func TestEtcdListPersistentVolumes(t *testing.T) {
...
@@ -149,7 +149,7 @@ func TestEtcdListPersistentVolumes(t *testing.T) {
}
}
func
TestEtcdGetPersistentVolumes
(
t
*
testing
.
T
)
{
func
TestEtcdGetPersistentVolumes
(
t
*
testing
.
T
)
{
ctx
:=
api
.
New
Default
Context
()
ctx
:=
api
.
NewContext
()
storage
,
_
,
fakeClient
,
_
:=
newStorage
(
t
)
storage
,
_
,
fakeClient
,
_
:=
newStorage
(
t
)
persistentVolume
:=
validNewPersistentVolume
(
"foo"
)
persistentVolume
:=
validNewPersistentVolume
(
"foo"
)
name
:=
persistentVolume
.
Name
name
:=
persistentVolume
.
Name
...
@@ -180,7 +180,7 @@ func TestEtcdGetPersistentVolumes(t *testing.T) {
...
@@ -180,7 +180,7 @@ func TestEtcdGetPersistentVolumes(t *testing.T) {
}
}
func
TestListEmptyPersistentVolumesList
(
t
*
testing
.
T
)
{
func
TestListEmptyPersistentVolumesList
(
t
*
testing
.
T
)
{
ctx
:=
api
.
New
Default
Context
()
ctx
:=
api
.
NewContext
()
storage
,
_
,
fakeClient
,
_
:=
newStorage
(
t
)
storage
,
_
,
fakeClient
,
_
:=
newStorage
(
t
)
fakeClient
.
ChangeIndex
=
1
fakeClient
.
ChangeIndex
=
1
key
:=
storage
.
KeyRootFunc
(
ctx
)
key
:=
storage
.
KeyRootFunc
(
ctx
)
...
@@ -204,7 +204,7 @@ func TestListEmptyPersistentVolumesList(t *testing.T) {
...
@@ -204,7 +204,7 @@ func TestListEmptyPersistentVolumesList(t *testing.T) {
}
}
func
TestListPersistentVolumesList
(
t
*
testing
.
T
)
{
func
TestListPersistentVolumesList
(
t
*
testing
.
T
)
{
ctx
:=
api
.
New
Default
Context
()
ctx
:=
api
.
NewContext
()
storage
,
_
,
fakeClient
,
_
:=
newStorage
(
t
)
storage
,
_
,
fakeClient
,
_
:=
newStorage
(
t
)
fakeClient
.
ChangeIndex
=
1
fakeClient
.
ChangeIndex
=
1
key
:=
storage
.
KeyRootFunc
(
ctx
)
key
:=
storage
.
KeyRootFunc
(
ctx
)
...
@@ -264,7 +264,7 @@ func TestPersistentVolumesDecode(t *testing.T) {
...
@@ -264,7 +264,7 @@ func TestPersistentVolumesDecode(t *testing.T) {
}
}
func
TestEtcdUpdatePersistentVolumes
(
t
*
testing
.
T
)
{
func
TestEtcdUpdatePersistentVolumes
(
t
*
testing
.
T
)
{
ctx
:=
api
.
New
Default
Context
()
ctx
:=
api
.
NewContext
()
storage
,
_
,
fakeClient
,
_
:=
newStorage
(
t
)
storage
,
_
,
fakeClient
,
_
:=
newStorage
(
t
)
persistentVolume
:=
validChangedPersistentVolume
()
persistentVolume
:=
validChangedPersistentVolume
()
...
@@ -294,7 +294,7 @@ func TestEtcdUpdatePersistentVolumes(t *testing.T) {
...
@@ -294,7 +294,7 @@ func TestEtcdUpdatePersistentVolumes(t *testing.T) {
}
}
func
TestDeletePersistentVolumes
(
t
*
testing
.
T
)
{
func
TestDeletePersistentVolumes
(
t
*
testing
.
T
)
{
ctx
:=
api
.
New
Default
Context
()
ctx
:=
api
.
NewContext
()
storage
,
_
,
fakeClient
,
_
:=
newStorage
(
t
)
storage
,
_
,
fakeClient
,
_
:=
newStorage
(
t
)
persistentVolume
:=
validNewPersistentVolume
(
"foo"
)
persistentVolume
:=
validNewPersistentVolume
(
"foo"
)
name
:=
persistentVolume
.
Name
name
:=
persistentVolume
.
Name
...
@@ -318,7 +318,7 @@ func TestDeletePersistentVolumes(t *testing.T) {
...
@@ -318,7 +318,7 @@ func TestDeletePersistentVolumes(t *testing.T) {
func
TestEtcdUpdateStatus
(
t
*
testing
.
T
)
{
func
TestEtcdUpdateStatus
(
t
*
testing
.
T
)
{
storage
,
statusStorage
,
fakeClient
,
helper
:=
newStorage
(
t
)
storage
,
statusStorage
,
fakeClient
,
helper
:=
newStorage
(
t
)
ctx
:=
api
.
New
Default
Context
()
ctx
:=
api
.
NewContext
()
fakeClient
.
TestIndex
=
true
fakeClient
.
TestIndex
=
true
key
,
_
:=
storage
.
KeyFunc
(
ctx
,
"foo"
)
key
,
_
:=
storage
.
KeyFunc
(
ctx
,
"foo"
)
...
...
pkg/registry/podtemplate/etcd/etcd_test.go
View file @
ad47b2d2
...
@@ -80,13 +80,18 @@ func TestUpdate(t *testing.T) {
...
@@ -80,13 +80,18 @@ func TestUpdate(t *testing.T) {
fakeEtcdClient
,
helper
:=
newHelper
(
t
)
fakeEtcdClient
,
helper
:=
newHelper
(
t
)
storage
:=
NewREST
(
helper
)
storage
:=
NewREST
(
helper
)
test
:=
resttest
.
New
(
t
,
storage
,
fakeEtcdClient
.
SetError
)
test
:=
resttest
.
New
(
t
,
storage
,
fakeEtcdClient
.
SetError
)
key
:=
etcdtest
.
AddPrefix
(
"podtemplates/default/foo"
)
key
,
err
:=
storage
.
KeyFunc
(
test
.
TestContext
(),
"foo"
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
key
=
etcdtest
.
AddPrefix
(
key
)
fakeEtcdClient
.
ExpectNotFoundGet
(
key
)
fakeEtcdClient
.
ExpectNotFoundGet
(
key
)
fakeEtcdClient
.
ChangeIndex
=
2
fakeEtcdClient
.
ChangeIndex
=
2
pod
:=
validNewPodTemplate
(
"foo"
)
pod
:=
validNewPodTemplate
(
"foo"
)
existing
:=
validNewPodTemplate
(
"exists"
)
existing
:=
validNewPodTemplate
(
"exists"
)
obj
,
err
:=
storage
.
Create
(
api
.
NewDefaultContext
(),
existing
)
existing
.
Namespace
=
test
.
TestNamespace
()
obj
,
err
:=
storage
.
Create
(
test
.
TestContext
(),
existing
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"unable to create object: %v"
,
err
)
t
.
Fatalf
(
"unable to create object: %v"
,
err
)
}
}
...
...
pkg/registry/secret/etcd/etcd_test.go
View file @
ad47b2d2
...
@@ -50,8 +50,7 @@ func TestCreate(t *testing.T) {
...
@@ -50,8 +50,7 @@ func TestCreate(t *testing.T) {
storage
:=
NewStorage
(
helper
)
storage
:=
NewStorage
(
helper
)
test
:=
resttest
.
New
(
t
,
storage
,
fakeEtcdClient
.
SetError
)
test
:=
resttest
.
New
(
t
,
storage
,
fakeEtcdClient
.
SetError
)
secret
:=
validNewSecret
(
"foo"
)
secret
:=
validNewSecret
(
"foo"
)
secret
.
Name
=
""
secret
.
ObjectMeta
=
api
.
ObjectMeta
{
GenerateName
:
"foo-"
}
secret
.
GenerateName
=
"foo-"
test
.
TestCreate
(
test
.
TestCreate
(
// valid
// valid
secret
,
secret
,
...
@@ -72,13 +71,18 @@ func TestUpdate(t *testing.T) {
...
@@ -72,13 +71,18 @@ func TestUpdate(t *testing.T) {
fakeEtcdClient
,
helper
:=
newHelper
(
t
)
fakeEtcdClient
,
helper
:=
newHelper
(
t
)
storage
:=
NewStorage
(
helper
)
storage
:=
NewStorage
(
helper
)
test
:=
resttest
.
New
(
t
,
storage
,
fakeEtcdClient
.
SetError
)
test
:=
resttest
.
New
(
t
,
storage
,
fakeEtcdClient
.
SetError
)
key
:=
etcdtest
.
AddPrefix
(
"secrets/default/foo"
)
key
,
err
:=
storage
.
KeyFunc
(
test
.
TestContext
(),
"foo"
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
key
=
etcdtest
.
AddPrefix
(
key
)
fakeEtcdClient
.
ExpectNotFoundGet
(
key
)
fakeEtcdClient
.
ExpectNotFoundGet
(
key
)
fakeEtcdClient
.
ChangeIndex
=
2
fakeEtcdClient
.
ChangeIndex
=
2
secret
:=
validNewSecret
(
"foo"
)
secret
:=
validNewSecret
(
"foo"
)
existing
:=
validNewSecret
(
"exists"
)
existing
:=
validNewSecret
(
"exists"
)
obj
,
err
:=
storage
.
Create
(
api
.
NewDefaultContext
(),
existing
)
existing
.
Namespace
=
test
.
TestNamespace
()
obj
,
err
:=
storage
.
Create
(
test
.
TestContext
(),
existing
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"unable to create object: %v"
,
err
)
t
.
Fatalf
(
"unable to create object: %v"
,
err
)
}
}
...
...
pkg/registry/serviceaccount/etcd/etcd_test.go
View file @
ad47b2d2
...
@@ -48,8 +48,7 @@ func TestCreate(t *testing.T) {
...
@@ -48,8 +48,7 @@ func TestCreate(t *testing.T) {
storage
:=
NewStorage
(
helper
)
storage
:=
NewStorage
(
helper
)
test
:=
resttest
.
New
(
t
,
storage
,
fakeEtcdClient
.
SetError
)
test
:=
resttest
.
New
(
t
,
storage
,
fakeEtcdClient
.
SetError
)
serviceAccount
:=
validNewServiceAccount
(
"foo"
)
serviceAccount
:=
validNewServiceAccount
(
"foo"
)
serviceAccount
.
Name
=
""
serviceAccount
.
ObjectMeta
=
api
.
ObjectMeta
{
GenerateName
:
"foo-"
}
serviceAccount
.
GenerateName
=
"foo-"
test
.
TestCreate
(
test
.
TestCreate
(
// valid
// valid
serviceAccount
,
serviceAccount
,
...
@@ -65,13 +64,18 @@ func TestUpdate(t *testing.T) {
...
@@ -65,13 +64,18 @@ func TestUpdate(t *testing.T) {
fakeEtcdClient
,
helper
:=
newHelper
(
t
)
fakeEtcdClient
,
helper
:=
newHelper
(
t
)
storage
:=
NewStorage
(
helper
)
storage
:=
NewStorage
(
helper
)
test
:=
resttest
.
New
(
t
,
storage
,
fakeEtcdClient
.
SetError
)
test
:=
resttest
.
New
(
t
,
storage
,
fakeEtcdClient
.
SetError
)
key
:=
etcdtest
.
AddPrefix
(
"serviceaccounts/default/foo"
)
key
,
err
:=
storage
.
KeyFunc
(
test
.
TestContext
(),
"foo"
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
key
=
etcdtest
.
AddPrefix
(
key
)
fakeEtcdClient
.
ExpectNotFoundGet
(
key
)
fakeEtcdClient
.
ExpectNotFoundGet
(
key
)
fakeEtcdClient
.
ChangeIndex
=
2
fakeEtcdClient
.
ChangeIndex
=
2
serviceAccount
:=
validNewServiceAccount
(
"foo"
)
serviceAccount
:=
validNewServiceAccount
(
"foo"
)
existing
:=
validNewServiceAccount
(
"exists"
)
existing
:=
validNewServiceAccount
(
"exists"
)
obj
,
err
:=
storage
.
Create
(
api
.
NewDefaultContext
(),
existing
)
existing
.
Namespace
=
test
.
TestNamespace
()
obj
,
err
:=
storage
.
Create
(
test
.
TestContext
(),
existing
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"unable to create object: %v"
,
err
)
t
.
Fatalf
(
"unable to create object: %v"
,
err
)
}
}
...
...
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