MCPcopy
hub / github.com/helm/helm / TestResolveChartOpts

Function TestResolveChartOpts

pkg/downloader/chart_downloader_test.go:102–161  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

100}
101
102func TestResolveChartOpts(t *testing.T) {
103 tests := []struct {
104 name, ref, version string
105 expect []getter.Option
106 }{
107 {
108 name: "repo with CA-file",
109 ref: "testing-ca-file/foo",
110 expect: []getter.Option{
111 getter.WithURL("https://example.com/foo-1.2.3.tgz"),
112 getter.WithTLSClientConfig("cert", "key", "ca"),
113 },
114 },
115 }
116
117 c := ChartDownloader{
118 Out: os.Stderr,
119 RepositoryConfig: repoConfig,
120 RepositoryCache: repoCache,
121 Getters: getter.All(&cli.EnvSettings{
122 RepositoryConfig: repoConfig,
123 RepositoryCache: repoCache,
124 }),
125 }
126
127 // snapshot options
128 snapshotOpts := c.Options
129
130 for _, tt := range tests {
131 // reset chart downloader options for each test case
132 c.Options = snapshotOpts
133
134 expect, err := getter.NewHTTPGetter(tt.expect...)
135 if err != nil {
136 t.Errorf("%s: failed to setup http client: %s", tt.name, err)
137 continue
138 }
139
140 _, u, err := c.ResolveChartVersion(tt.ref, tt.version)
141 if err != nil {
142 t.Errorf("%s: failed with error %s", tt.name, err)
143 continue
144 }
145
146 got, err := getter.NewHTTPGetter(
147 append(
148 c.Options,
149 getter.WithURL(u.String()),
150 )...,
151 )
152 if err != nil {
153 t.Errorf("%s: failed to create http client: %s", tt.name, err)
154 continue
155 }
156
157 if *(got.(*getter.HTTPGetter)) != *(expect.(*getter.HTTPGetter)) {
158 t.Errorf("%s: expected %s, got %s", tt.name, expect, got)
159 }

Callers

nothing calls this directly

Calls 6

ResolveChartVersionMethod · 0.95
WithURLFunction · 0.92
WithTLSClientConfigFunction · 0.92
AllFunction · 0.92
NewHTTPGetterFunction · 0.92
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…