mirror of
https://github.com/helm/helm.git
synced 2026-05-28 04:35:48 -04:00
add unit test for function FindPlugins
Signed-off-by: ZouYu <zouy.fnst@cn.fujitsu.com>
This commit is contained in:
parent
fa5eb64f32
commit
df9cf87cbe
1 changed files with 37 additions and 0 deletions
|
|
@ -264,6 +264,43 @@ func TestLoadAll(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestFindPlugins(t *testing.T) {
|
||||
cases := []struct {
|
||||
name string
|
||||
plugdirs string
|
||||
expected int
|
||||
}{
|
||||
{
|
||||
name: "plugdirs is empty",
|
||||
plugdirs: "",
|
||||
expected: 0,
|
||||
},
|
||||
{
|
||||
name: "plugdirs isn't dir",
|
||||
plugdirs: "./plugin_test.go",
|
||||
expected: 0,
|
||||
},
|
||||
{
|
||||
name: "plugdirs doens't have plugin",
|
||||
plugdirs: ".",
|
||||
expected: 0,
|
||||
},
|
||||
{
|
||||
name: "normal",
|
||||
plugdirs: "./testdata/plugdir",
|
||||
expected: 3,
|
||||
},
|
||||
}
|
||||
for _, c := range cases {
|
||||
t.Run(t.Name(), func(t *testing.T) {
|
||||
plugin, _ := FindPlugins(c.plugdirs)
|
||||
if len(plugin) != c.expected {
|
||||
t.Errorf("expected: %v, got: %v", c.expected, len(plugin))
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestSetupEnv(t *testing.T) {
|
||||
name := "pequod"
|
||||
base := filepath.Join("testdata/helmhome/helm/plugins", name)
|
||||
|
|
|
|||
Loading…
Reference in a new issue