(t *testing.T)
| 161 | } |
| 162 | |
| 163 | func TestHTTPInstallerUpdate(t *testing.T) { |
| 164 | srv := mockArchiveServer() |
| 165 | defer srv.Close() |
| 166 | source := srv.URL + "/plugins/fake-plugin-0.0.1.tar.gz" |
| 167 | ensure.HelmHome(t) |
| 168 | |
| 169 | if err := os.MkdirAll(helmpath.DataPath("plugins"), 0755); err != nil { |
| 170 | t.Fatalf("Could not create %s: %s", helmpath.DataPath("plugins"), err) |
| 171 | } |
| 172 | |
| 173 | i, err := NewForSource(source, "0.0.1") |
| 174 | if err != nil { |
| 175 | t.Fatalf("unexpected error: %s", err) |
| 176 | } |
| 177 | |
| 178 | // ensure a HTTPInstaller was returned |
| 179 | httpInstaller, ok := i.(*HTTPInstaller) |
| 180 | if !ok { |
| 181 | t.Fatal("expected a HTTPInstaller") |
| 182 | } |
| 183 | |
| 184 | // inject fake http client responding with minimal plugin tarball |
| 185 | mockTgz, err := base64.StdEncoding.DecodeString(fakePluginB64) |
| 186 | if err != nil { |
| 187 | t.Fatalf("Could not decode fake tgz plugin: %s", err) |
| 188 | } |
| 189 | |
| 190 | httpInstaller.getter = &TestHTTPGetter{ |
| 191 | MockResponse: bytes.NewBuffer(mockTgz), |
| 192 | } |
| 193 | |
| 194 | // install the plugin before updating |
| 195 | if err := Install(i); err != nil { |
| 196 | t.Fatal(err) |
| 197 | } |
| 198 | if i.Path() != helmpath.DataPath("plugins", "fake-plugin") { |
| 199 | t.Fatalf("expected path '$XDG_CONFIG_HOME/helm/plugins/fake-plugin', got %q", i.Path()) |
| 200 | } |
| 201 | |
| 202 | // Update plugin, should fail because it is not implemented |
| 203 | if err := Update(i); err == nil { |
| 204 | t.Fatal("update method not implemented for http installer") |
| 205 | } |
| 206 | } |
| 207 | |
| 208 | func TestExtract(t *testing.T) { |
| 209 | source := "https://repo.localdomain/plugins/fake-plugin-0.0.1.tar.gz" |
nothing calls this directly
no test coverage detected
searching dependent graphs…