(suite *TestRegistry)
| 380 | } |
| 381 | |
| 382 | func 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)) |
no test coverage detected
searching dependent graphs…