mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 12:15:52 +00:00
Merge pull request #37064 from NickrenREN/vpmtest
Automatic merge from submit-queue VolumePluginMgrFunc test Add test func to test VolumePluginMgr funcs in pkg/volume/plugins_test.go
This commit is contained in:
commit
2ac9c08781
@ -61,6 +61,7 @@ go_test(
|
||||
"//pkg/api/errors:go_default_library",
|
||||
"//pkg/api/resource:go_default_library",
|
||||
"//pkg/api/v1:go_default_library",
|
||||
"//pkg/types:go_default_library",
|
||||
"//pkg/util/testing:go_default_library",
|
||||
"//pkg/watch:go_default_library",
|
||||
],
|
||||
|
@ -20,6 +20,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"k8s.io/kubernetes/pkg/api/v1"
|
||||
"k8s.io/kubernetes/pkg/types"
|
||||
)
|
||||
|
||||
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())
|
||||
}
|
||||
}
|
||||
|
||||
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())
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user