MCPcopy Index your code
hub / github.com/docker/cli / TestLoadDanglingSymlink

Function TestLoadDanglingSymlink

cli/config/config_test.go:56–72  ·  view source on GitHub ↗

TestLoadDanglingSymlink verifies that we gracefully handle dangling symlinks. TODO(thaJeztah): consider whether we want dangling symlinks to be an error condition instead.

(t *testing.T)

Source from the content-addressed store, hash-verified

54//
55// TODO(thaJeztah): consider whether we want dangling symlinks to be an error condition instead.
56func TestLoadDanglingSymlink(t *testing.T) {
57 cfgDir := t.TempDir()
58 cfgFile := filepath.Join(cfgDir, ConfigFileName)
59 err := os.Symlink(filepath.Join(cfgDir, "no-such-file"), cfgFile)
60 assert.NilError(t, err)
61
62 config, err := Load(cfgDir)
63 assert.NilError(t, err)
64
65 // Now save it and make sure it shows up in new form
66 saveConfigAndValidateNewFormat(t, config, cfgDir)
67
68 // Make sure we kept the symlink.
69 fi, err := os.Lstat(cfgFile)
70 assert.NilError(t, err)
71 assert.Equal(t, fi.Mode()&os.ModeSymlink, os.ModeSymlink, "expected %v to be a symlink", cfgFile)
72}
73
74func TestLoadNoPermissions(t *testing.T) {
75 if runtime.GOOS != "windows" {

Callers

nothing calls this directly

Calls 3

ModeMethod · 0.80
LoadFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…