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

Function TestHttpGetter_metaSubdir

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

Source from the content-addressed store, hash-verified

150}
151
152func TestHttpGetter_metaSubdir(t *testing.T) {
153 ln := testHttpServer(t)
154 defer ln.Close()
155 ctx := context.Background()
156
157 g := new(HttpGetter)
158 dst := testing_helper.TempDir(t)
159 defer os.RemoveAll(dst)
160
161 var u url.URL
162 u.Scheme = "http"
163 u.Host = ln.Addr().String()
164 u.Path = "/meta-subdir"
165
166 req := &Request{
167 Dst: dst,
168 Src: u.String(),
169 u: &u,
170 GetMode: ModeDir,
171 }
172
173 // Get it, which should error because it uses the file protocol.
174 err := g.Get(ctx, req)
175 if !strings.Contains(err.Error(), "error downloading") {
176 t.Fatalf("unexpected error: %v", err)
177 }
178 // But, using a wrapper client with a file getter will work.
179 c := &Client{
180 Getters: []Getter{
181 g,
182 new(FileGetter),
183 },
184 }
185
186 if _, err = c.Get(ctx, req); err != nil {
187 t.Fatalf("err: %s", err)
188 }
189
190 // Verify the main file exists
191 mainPath := filepath.Join(dst, "sub.tf")
192 if _, err := os.Stat(mainPath); err != nil {
193 t.Fatalf("err: %s", err)
194 }
195}
196
197func TestHttpGetter_metaSubdirGlob(t *testing.T) {
198 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