Merge pull request #7934 from Hellcatlk/UnitTest

Add unit test for function FindPlugins
pull/7936/head
Martin Hickey 5 years ago committed by GitHub
commit f860e08f2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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…
Cancel
Save