MCPcopy
hub / github.com/helm/helm / testPush

Function testPush

pkg/registry/registry_test.go:382–467  ·  view source on GitHub ↗
(suite *TestRegistry)

Source from the content-addressed store, hash-verified

380}
381
382func testPush(suite *TestRegistry) {
383
384 testingChartCreationTime := "1977-09-02T22:04:05Z"
385
386 // Bad bytes
387 ref := suite.DockerRegistryHost + "/testrepo/testchart:1.2.3"
388 _, err := suite.RegistryClient.Push([]byte("hello"), ref, PushOptCreationTime(testingChartCreationTime))
389 suite.NotNil(err, "error pushing non-chart bytes")
390
391 // Load a test chart
392 chartData, err := os.ReadFile("../repo/v1/repotest/testdata/examplechart-0.1.0.tgz")
393 suite.Nil(err, "no error loading test chart")
394 meta, err := extractChartMeta(chartData)
395 suite.Nil(err, "no error extracting chart meta")
396
397 // non-strict ref (chart name)
398 ref = fmt.Sprintf("%s/testrepo/boop:%s", suite.DockerRegistryHost, meta.Version)
399 _, err = suite.RegistryClient.Push(chartData, ref, PushOptCreationTime(testingChartCreationTime))
400 suite.NotNil(err, "error pushing non-strict ref (bad basename)")
401
402 // non-strict ref (chart name), with strict mode disabled
403 _, err = suite.RegistryClient.Push(chartData, ref, PushOptStrictMode(false), PushOptCreationTime(testingChartCreationTime))
404 suite.Nil(err, "no error pushing non-strict ref (bad basename), with strict mode disabled")
405
406 // non-strict ref (chart version)
407 ref = fmt.Sprintf("%s/testrepo/%s:latest", suite.DockerRegistryHost, meta.Name)
408 _, err = suite.RegistryClient.Push(chartData, ref, PushOptCreationTime(testingChartCreationTime))
409 suite.NotNil(err, "error pushing non-strict ref (bad tag)")
410
411 // non-strict ref (chart version), with strict mode disabled
412 _, err = suite.RegistryClient.Push(chartData, ref, PushOptStrictMode(false), PushOptCreationTime(testingChartCreationTime))
413 suite.Nil(err, "no error pushing non-strict ref (bad tag), with strict mode disabled")
414
415 // basic push, good ref
416 chartData, err = os.ReadFile("../downloader/testdata/local-subchart-0.1.0.tgz")
417 suite.Nil(err, "no error loading test chart")
418 meta, err = extractChartMeta(chartData)
419 suite.Nil(err, "no error extracting chart meta")
420 ref = fmt.Sprintf("%s/testrepo/%s:%s", suite.DockerRegistryHost, meta.Name, meta.Version)
421 _, err = suite.RegistryClient.Push(chartData, ref, PushOptCreationTime(testingChartCreationTime))
422 suite.Nil(err, "no error pushing good ref")
423
424 _, err = suite.RegistryClient.Pull(ref)
425 suite.Nil(err, "no error pulling a simple chart")
426
427 // Load another test chart
428 chartData, err = os.ReadFile("../downloader/testdata/signtest-0.1.0.tgz")
429 suite.Nil(err, "no error loading test chart")
430 meta, err = extractChartMeta(chartData)
431 suite.Nil(err, "no error extracting chart meta")
432
433 // Load prov file
434 provData, err := os.ReadFile("../downloader/testdata/signtest-0.1.0.tgz.prov")
435 suite.Nil(err, "no error loading test prov")
436
437 // push with prov
438 ref = fmt.Sprintf("%s/testrepo/%s:%s", suite.DockerRegistryHost, meta.Name, meta.Version)
439 result, err := suite.RegistryClient.Push(chartData, ref, PushOptProvData(provData), PushOptCreationTime(testingChartCreationTime))

Callers 3

Test_1_PushMethod · 0.85
Test_1_PushMethod · 0.85
Test_1_PushMethod · 0.85

Calls 7

PushOptCreationTimeFunction · 0.85
extractChartMetaFunction · 0.85
PushOptStrictModeFunction · 0.85
PushOptProvDataFunction · 0.85
PullOptWithProvFunction · 0.85
PullMethod · 0.80
PushMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…