...
1
15
16 package installer
17
18 import (
19 "os"
20 "path/filepath"
21 "testing"
22
23 "helm.sh/helm/v3/pkg/helmpath"
24 )
25
26 var _ Installer = new(LocalInstaller)
27
28 func TestLocalInstaller(t *testing.T) {
29
30 tdir := t.TempDir()
31 if err := os.WriteFile(filepath.Join(tdir, "plugin.yaml"), []byte{}, 0644); err != nil {
32 t.Fatal(err)
33 }
34
35 source := "../testdata/plugdir/good/echo"
36 i, err := NewForSource(source, "")
37 if err != nil {
38 t.Fatalf("unexpected error: %s", err)
39 }
40
41 if err := Install(i); err != nil {
42 t.Fatal(err)
43 }
44
45 if i.Path() != helmpath.DataPath("plugins", "echo") {
46 t.Fatalf("expected path '$XDG_CONFIG_HOME/helm/plugins/helm-env', got %q", i.Path())
47 }
48 defer os.RemoveAll(filepath.Dir(helmpath.DataPath()))
49 }
50
51 func TestLocalInstallerNotAFolder(t *testing.T) {
52 source := "../testdata/plugdir/good/echo/plugin.yaml"
53 i, err := NewForSource(source, "")
54 if err != nil {
55 t.Fatalf("unexpected error: %s", err)
56 }
57
58 err = Install(i)
59 if err == nil {
60 t.Fatal("expected error")
61 }
62 if err != ErrPluginNotAFolder {
63 t.Fatalf("expected error to equal: %q", err)
64 }
65 }
66
View as plain text