MCPcopy
hub / github.com/hashicorp/go-getter / TestHttpGetter_metaSubdirGlob

Function TestHttpGetter_metaSubdirGlob

get_http_test.go:197–240  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

195}
196
197func TestHttpGetter_metaSubdirGlob(t *testing.T) {
198 ln := testHttpServer(t)
199 defer ln.Close()
200 ctx := context.Background()
201
202 g := new(HttpGetter)
203 dst := testing_helper.TempDir(t)
204 defer os.RemoveAll(dst)
205
206 var u url.URL
207 u.Scheme = "http"
208 u.Host = ln.Addr().String()
209 u.Path = "/meta-subdir-glob"
210
211 req := &Request{
212 Dst: dst,
213 Src: u.String(),
214 u: &u,
215 GetMode: ModeDir,
216 }
217
218 // Get it, which should error because it uses the file protocol.
219 err := g.Get(ctx, req)
220 if !strings.Contains(err.Error(), "error downloading") {
221 t.Fatalf("unexpected error: %v", err)
222 }
223 // But, using a wrapper client with a file getter will work.
224 c := &Client{
225 Getters: []Getter{
226 g,
227 new(FileGetter),
228 },
229 }
230
231 if _, err = c.Get(ctx, req); err != nil {
232 t.Fatalf("err: %s", err)
233 }
234
235 // Verify the main file exists
236 mainPath := filepath.Join(dst, "sub.tf")
237 if _, err := os.Stat(mainPath); err != nil {
238 t.Fatalf("err: %s", err)
239 }
240}
241
242func TestHttpGetter_none(t *testing.T) {
243 ln := testHttpServer(t)

Callers

nothing calls this directly

Calls 6

GetMethod · 0.95
testHttpServerFunction · 0.85
GetMethod · 0.65
CloseMethod · 0.45
StringMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected