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

Function TestFolderStorage

folder_storage_test.go:16–52  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

14}
15
16func TestFolderStorage(t *testing.T) {
17 s := &FolderStorage{StorageDir: testing_helper.TempDir(t)}
18 ctx := context.Background()
19
20 module := testModule("basic")
21
22 // A module shouldn't exist at first...
23 _, ok, err := s.Dir(module)
24 if err != nil {
25 t.Fatalf("err: %s", err)
26 }
27 if ok {
28 t.Fatal("should not exist")
29 }
30
31 key := "foo"
32
33 // We can get it
34 err = s.Get(ctx, key, module, false)
35 if err != nil {
36 t.Fatalf("err: %s", err)
37 }
38
39 // Now the module exists
40 dir, ok, err := s.Dir(key)
41 if err != nil {
42 t.Fatalf("err: %s", err)
43 }
44 if !ok {
45 t.Fatal("should exist")
46 }
47
48 mainPath := filepath.Join(dir, "main.tf")
49 if _, err := os.Stat(mainPath); err != nil {
50 t.Fatalf("err: %s", err)
51 }
52}

Callers

nothing calls this directly

Calls 3

DirMethod · 0.95
GetMethod · 0.95
testModuleFunction · 0.85

Tested by

no test coverage detected