MCPcopy Index your code
hub / github.com/helm/helm / TestHTTPInstallerUpdate

Function TestHTTPInstallerUpdate

internal/plugin/installer/http_installer_test.go:163–206  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

161}
162
163func 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
208func TestExtract(t *testing.T) {
209 source := "https://repo.localdomain/plugins/fake-plugin-0.0.1.tar.gz"

Callers

nothing calls this directly

Calls 10

HelmHomeFunction · 0.92
DataPathFunction · 0.92
mockArchiveServerFunction · 0.85
NewForSourceFunction · 0.85
UpdateFunction · 0.85
CloseMethod · 0.80
FatalfMethod · 0.80
FatalMethod · 0.80
InstallFunction · 0.70
PathMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…