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

Function TestSourceDirSubdir

source_test.go:10–54  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

8)
9
10func TestSourceDirSubdir(t *testing.T) {
11 cases := []struct {
12 Input string
13 Dir, Sub string
14 }{
15 {
16 "hashicorp.com",
17 "hashicorp.com", "",
18 },
19 {
20 "hashicorp.com//foo",
21 "hashicorp.com", "foo",
22 },
23 {
24 "hashicorp.com//foo?bar=baz",
25 "hashicorp.com?bar=baz", "foo",
26 },
27 {
28 "https://hashicorp.com/path//*?archive=foo",
29 "https://hashicorp.com/path?archive=foo", "*",
30 },
31 {
32 "https://hashicorp.com/path?checksum=file:http://url.com/....iso.sha256",
33 "https://hashicorp.com/path?checksum=file:http://url.com/....iso.sha256", "",
34 },
35 {
36 "https://hashicorp.com/path//*?checksum=file:http://url.com/....iso.sha256",
37 "https://hashicorp.com/path?checksum=file:http://url.com/....iso.sha256", "*",
38 },
39 {
40 "file://foo//bar",
41 "file://foo", "bar",
42 },
43 }
44
45 for i, tc := range cases {
46 adir, asub := SourceDirSubdir(tc.Input)
47 if adir != tc.Dir {
48 t.Fatalf("%d: bad dir: %#v", i, adir)
49 }
50 if asub != tc.Sub {
51 t.Fatalf("%d: bad sub: %#v", i, asub)
52 }
53 }
54}
55
56func TestSourceSubdirGlob(t *testing.T) {
57 td, err := ioutil.TempDir("", "subdir-glob")

Callers

nothing calls this directly

Calls 1

SourceDirSubdirFunction · 0.85

Tested by

no test coverage detected