MCPcopy
hub / github.com/helm/helm / TestDependencyUpdateCmd

Function TestDependencyUpdateCmd

pkg/cmd/dependency_update_test.go:36–152  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

34)
35
36func TestDependencyUpdateCmd(t *testing.T) {
37 srv := repotest.NewTempServer(
38 t,
39 repotest.WithChartSourceGlob("testdata/testcharts/*.tgz"),
40 )
41 defer srv.Stop()
42 t.Logf("Listening on directory %s", srv.Root())
43
44 ociSrv, err := repotest.NewOCIServer(t, srv.Root())
45 if err != nil {
46 t.Fatal(err)
47 }
48 contentCache := t.TempDir()
49
50 ociChartName := "oci-depending-chart"
51 c := createTestingMetadataForOCI(ociChartName, ociSrv.RegistryURL)
52 if _, err := chartutil.Save(c, ociSrv.Dir); err != nil {
53 t.Fatal(err)
54 }
55 ociSrv.Run(t, repotest.WithDependingChart(c))
56
57 if err := srv.LinkIndices(); err != nil {
58 t.Fatal(err)
59 }
60
61 dir := func(p ...string) string {
62 return filepath.Join(append([]string{srv.Root()}, p...)...)
63 }
64
65 chartname := "depup"
66 ch := createTestingMetadata(chartname, srv.URL())
67 md := ch.Metadata
68 if err := chartutil.SaveDir(ch, dir()); err != nil {
69 t.Fatal(err)
70 }
71
72 _, out, err := executeActionCommand(
73 fmt.Sprintf("dependency update '%s' --repository-config %s --repository-cache %s --content-cache %s --plain-http", dir(chartname), dir("repositories.yaml"), dir(), contentCache),
74 )
75 if err != nil {
76 t.Logf("Output: %s", out)
77 t.Fatal(err)
78 }
79
80 // This is written directly to stdout, so we have to capture as is.
81 if !strings.Contains(out, `update from the "test" chart repository`) {
82 t.Errorf("Repo did not get updated\n%s", out)
83 }
84
85 // Make sure the actual file got downloaded.
86 expect := dir(chartname, "charts/reqtest-0.1.0.tgz")
87 if _, err := os.Stat(expect); err != nil {
88 t.Fatal(err)
89 }
90
91 hash, err := provenance.DigestFile(expect)
92 if err != nil {
93 t.Fatal(err)

Callers

nothing calls this directly

Calls 15

RunMethod · 0.95
NewTempServerFunction · 0.92
WithChartSourceGlobFunction · 0.92
NewOCIServerFunction · 0.92
WithDependingChartFunction · 0.92
DigestFileFunction · 0.92
CacheIndexFileFunction · 0.92
createTestingMetadataFunction · 0.85
executeActionCommandFunction · 0.85
StopMethod · 0.80
FatalMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…