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

Function TestFileGetter_GetFile

get_file_test.go:140–167  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

138}
139
140func TestFileGetter_GetFile(t *testing.T) {
141 g := new(FileGetter)
142 dst := testing_helper.TempTestFile(t)
143 defer os.RemoveAll(filepath.Dir(dst))
144 ctx := context.Background()
145
146 req := &Request{
147 Dst: dst,
148 u: testModuleURL("basic-file/foo.txt"),
149 }
150
151 // With a dir that doesn't exist
152 if err := g.GetFile(ctx, req); err != nil {
153 t.Fatalf("err: %s", err)
154 }
155
156 // Verify the destination folder is a symlink
157 fi, err := os.Lstat(dst)
158 if err != nil {
159 t.Fatalf("err: %s", err)
160 }
161 if fi.Mode()&os.ModeSymlink == 0 {
162 t.Fatal("destination is not a symlink")
163 }
164
165 // Verify the main file exists
166 testing_helper.AssertContents(t, dst, "Hello\n")
167}
168
169func TestFileGetter_GetFile_Copy(t *testing.T) {
170 g := new(FileGetter)

Callers

nothing calls this directly

Calls 4

testModuleURLFunction · 0.85
DirMethod · 0.65
GetFileMethod · 0.65
ModeMethod · 0.65

Tested by

no test coverage detected