(t *testing.T)
| 79 | } |
| 80 | |
| 81 | func TestHTTPInstaller(t *testing.T) { |
| 82 | ensure.HelmHome(t) |
| 83 | |
| 84 | srv := mockArchiveServer() |
| 85 | defer srv.Close() |
| 86 | source := srv.URL + "/plugins/fake-plugin-0.0.1.tar.gz" |
| 87 | |
| 88 | if err := os.MkdirAll(helmpath.DataPath("plugins"), 0755); err != nil { |
| 89 | t.Fatalf("Could not create %s: %s", helmpath.DataPath("plugins"), err) |
| 90 | } |
| 91 | |
| 92 | i, err := NewForSource(source, "0.0.1") |
| 93 | if err != nil { |
| 94 | t.Fatalf("unexpected error: %s", err) |
| 95 | } |
| 96 | |
| 97 | // ensure a HTTPInstaller was returned |
| 98 | httpInstaller, ok := i.(*HTTPInstaller) |
| 99 | if !ok { |
| 100 | t.Fatal("expected a HTTPInstaller") |
| 101 | } |
| 102 | |
| 103 | // inject fake http client responding with minimal plugin tarball |
| 104 | mockTgz, err := base64.StdEncoding.DecodeString(fakePluginB64) |
| 105 | if err != nil { |
| 106 | t.Fatalf("Could not decode fake tgz plugin: %s", err) |
| 107 | } |
| 108 | |
| 109 | httpInstaller.getter = &TestHTTPGetter{ |
| 110 | MockResponse: bytes.NewBuffer(mockTgz), |
| 111 | } |
| 112 | |
| 113 | // install the plugin |
| 114 | if err := Install(i); err != nil { |
| 115 | t.Fatal(err) |
| 116 | } |
| 117 | if i.Path() != helmpath.DataPath("plugins", "fake-plugin") { |
| 118 | t.Fatalf("expected path '$XDG_CONFIG_HOME/helm/plugins/fake-plugin', got %q", i.Path()) |
| 119 | } |
| 120 | |
| 121 | // Install again to test plugin exists error |
| 122 | if err := Install(i); err == nil { |
| 123 | t.Fatal("expected error for plugin exists, got none") |
| 124 | } else if err.Error() != "plugin already exists" { |
| 125 | t.Fatalf("expected error for plugin exists, got (%v)", err) |
| 126 | } |
| 127 | |
| 128 | } |
| 129 | |
| 130 | func TestHTTPInstallerNonExistentVersion(t *testing.T) { |
| 131 | ensure.HelmHome(t) |
nothing calls this directly
no test coverage detected
searching dependent graphs…