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
6a4b671a
Commit
6a4b671a
authored
Nov 18, 2016
by
NickrenREN
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
volume pluginsmgr functions test
add function to test vpm functions in pkg/volume/plugins_test.go
parent
69170e72
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
0 deletions
+54
-0
BUILD
pkg/volume/BUILD
+1
-0
plugins_test.go
pkg/volume/plugins_test.go
+53
-0
No files found.
pkg/volume/BUILD
View file @
6a4b671a
...
@@ -61,6 +61,7 @@ go_test(
...
@@ -61,6 +61,7 @@ go_test(
"//pkg/api/errors:go_default_library",
"//pkg/api/errors:go_default_library",
"//pkg/api/resource:go_default_library",
"//pkg/api/resource:go_default_library",
"//pkg/api/v1:go_default_library",
"//pkg/api/v1:go_default_library",
"//pkg/types:go_default_library",
"//pkg/util/testing:go_default_library",
"//pkg/util/testing:go_default_library",
"//pkg/watch:go_default_library",
"//pkg/watch:go_default_library",
],
],
...
...
pkg/volume/plugins_test.go
View file @
6a4b671a
...
@@ -20,6 +20,7 @@ import (
...
@@ -20,6 +20,7 @@ import (
"testing"
"testing"
"k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/types"
)
)
func
TestSpecSourceConverters
(
t
*
testing
.
T
)
{
func
TestSpecSourceConverters
(
t
*
testing
.
T
)
{
...
@@ -51,3 +52,55 @@ func TestSpecSourceConverters(t *testing.T) {
...
@@ -51,3 +52,55 @@ func TestSpecSourceConverters(t *testing.T) {
t
.
Errorf
(
"Expected %v but got %v"
,
pv
.
Name
,
converted
.
Name
())
t
.
Errorf
(
"Expected %v but got %v"
,
pv
.
Name
,
converted
.
Name
())
}
}
}
}
type
testPlugins
struct
{
}
func
(
plugin
*
testPlugins
)
Init
(
host
VolumeHost
)
error
{
return
nil
}
func
(
plugin
*
testPlugins
)
GetPluginName
()
string
{
return
"testPlugin"
}
func
(
plugin
*
testPlugins
)
GetVolumeName
(
spec
*
Spec
)
(
string
,
error
)
{
return
""
,
nil
}
func
(
plugin
*
testPlugins
)
CanSupport
(
spec
*
Spec
)
bool
{
return
true
}
func
(
plugin
*
testPlugins
)
RequiresRemount
()
bool
{
return
false
}
func
(
plugin
*
testPlugins
)
NewMounter
(
spec
*
Spec
,
podRef
*
v1
.
Pod
,
opts
VolumeOptions
)
(
Mounter
,
error
)
{
return
nil
,
nil
}
func
(
plugin
*
testPlugins
)
NewUnmounter
(
name
string
,
podUID
types
.
UID
)
(
Unmounter
,
error
)
{
return
nil
,
nil
}
func
(
plugin
*
testPlugins
)
ConstructVolumeSpec
(
volumeName
,
mountPath
string
)
(
*
Spec
,
error
)
{
return
nil
,
nil
}
func
newTestPlugin
()
[]
VolumePlugin
{
return
[]
VolumePlugin
{
&
testPlugins
{}}
}
func
TestVolumePluginMgrFunc
(
t
*
testing
.
T
)
{
vpm
:=
VolumePluginMgr
{}
vpm
.
InitPlugins
(
newTestPlugin
(),
nil
)
plug
,
err
:=
vpm
.
FindPluginByName
(
"testPlugin"
)
if
err
!=
nil
{
t
.
Errorf
(
"Can't find the plugin by name"
)
}
if
plug
.
GetPluginName
()
!=
"testPlugin"
{
t
.
Errorf
(
"Wrong name: %s"
,
plug
.
GetPluginName
())
}
}
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