MCPcopy Create free account
hub / github.com/cli/cli / TestReparsePointClassification

Function TestReparsePointClassification

internal/safepaths/link_windows_test.go:17–56  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

15)
16
17func TestReparsePointClassification(t *testing.T) {
18 t.Run("name surrogate redirects", func(t *testing.T) {
19 info := reparsePointInfo{mode: fs.ModeSymlink}
20 redirect, err := classifyWindowsPathRedirect(info, func() error {
21 return errors.New("should not be called")
22 })
23 require.NoError(t, err)
24 assert.True(t, redirect)
25 })
26 t.Run("mount point redirects", func(t *testing.T) {
27 info := reparsePointInfo{
28 mode: fs.ModeIrregular,
29 attributes: syscall.FILE_ATTRIBUTE_REPARSE_POINT,
30 }
31 redirect, err := classifyWindowsPathRedirect(info, func() error { return nil })
32 require.NoError(t, err)
33 assert.True(t, redirect)
34 })
35 t.Run("non-link reparse point fails closed", func(t *testing.T) {
36 info := reparsePointInfo{
37 mode: fs.ModeDir,
38 attributes: syscall.FILE_ATTRIBUTE_REPARSE_POINT,
39 }
40 redirect, err := classifyWindowsPathRedirect(info, func() error { return os.ErrNotExist })
41 assert.False(t, redirect)
42 require.ErrorIs(t, err, errUnsupportedNonLinkReparse)
43 })
44 t.Run("unexpected readlink error is returned", func(t *testing.T) {
45 info := reparsePointInfo{
46 mode: fs.ModeIrregular,
47 attributes: syscall.FILE_ATTRIBUTE_REPARSE_POINT,
48 }
49
50 redirect, err := classifyWindowsPathRedirect(info, func() error {
51 return errors.New("readlink failed")
52 })
53 assert.False(t, redirect)
54 require.ErrorContains(t, err, "readlink failed")
55 })
56}
57
58func TestCreateReplaceFailsClosedForNonLinkReparse(t *testing.T) {
59 rootDir := t.TempDir()

Callers

nothing calls this directly

Calls 2

RunMethod · 0.65

Tested by

no test coverage detected