MCPcopy
hub / github.com/git-lfs/git-lfs / TestCloneFileByPath

Function TestCloneFileByPath

tools/util_darwin_test.go:39–73  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

37}
38
39func TestCloneFileByPath(t *testing.T) {
40 if !cloneFileSupported {
41 t.Skip("clone not supported on this platform")
42 }
43
44 src := path.Join(os.TempDir(), "src")
45 t.Logf("src = %s", src)
46
47 dst := path.Join(os.TempDir(), "dst")
48 t.Logf("dst = %s", dst)
49
50 as := assert.New(t)
51
52 // Precondition
53 err := os.WriteFile(src, []byte("TEST"), 0666)
54 as.NoError(err)
55
56 // Do
57 ok, err := CloneFileByPath(dst, src)
58 if err != nil {
59 if cloneFileError, ok := err.(*CloneFileError); ok && cloneFileError.Unsupported {
60 t.Log(err)
61 t.Skip("tmp file is not support clonefile in this os installation.")
62 }
63 t.Error(err)
64 }
65
66 // Verify
67 as.NoError(err)
68 as.True(ok)
69
70 dstContents, err := os.ReadFile(dst)
71 as.NoError(err)
72 as.Equal("TEST", string(dstContents))
73}

Callers

nothing calls this directly

Calls 7

LogfMethod · 0.80
LogMethod · 0.80
CloneFileByPathFunction · 0.70
SkipMethod · 0.65
ErrorMethod · 0.65
TempDirMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected